Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af6cf88b5a | ||
|
|
5c05778614 | ||
|
|
785d96ea50 | ||
|
|
af4c7b5df9 | ||
|
|
d720da721b | ||
|
|
24b03d4caf | ||
|
|
2aac228cdc | ||
|
|
d79e261e09 | ||
|
|
8b9a086fd6 | ||
|
|
c3c9f509bf | ||
|
|
931ac2fad4 | ||
|
|
ec0421e9fd | ||
|
|
55f3569e55 | ||
|
|
b9c3369e7b | ||
|
|
64e6b9664a | ||
|
|
67ee52624c | ||
|
|
0d2e573e0d | ||
|
|
bd416f7327 | ||
|
|
23e52c80de | ||
|
|
84084bba37 | ||
|
|
efd7d788d9 | ||
|
|
b1c510a097 | ||
|
|
5f3680a0fb | ||
|
|
4ff91e8d6e | ||
|
|
5f3a7f5975 | ||
|
|
043ffdfad6 | ||
|
|
6a4634dcf1 | ||
|
|
84804be9f8 |
@@ -30,3 +30,7 @@ coverage/
|
|||||||
data/
|
data/
|
||||||
sessions/
|
sessions/
|
||||||
workspace-registry/
|
workspace-registry/
|
||||||
|
|
||||||
|
.tht/
|
||||||
|
|
||||||
|
deploy/local/
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- "docs/**"
|
- "docs/**"
|
||||||
- "mkdocs.yml"
|
- "mkdocs.yml"
|
||||||
|
- "scripts/build-docs.sh"
|
||||||
|
- "scripts/verify-public-docs.py"
|
||||||
|
- "scripts/test-verify-public-docs.py"
|
||||||
|
- "scripts/verify-auth-docs.py"
|
||||||
|
- "scripts/test-verify-auth-docs.py"
|
||||||
- "docs/requirements.txt"
|
- "docs/requirements.txt"
|
||||||
- ".gitea/workflows/publish-docs.yml"
|
- ".gitea/workflows/publish-docs.yml"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -34,14 +39,25 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
python-version: "3.x"
|
||||||
cache: pip
|
cache: pip
|
||||||
cache-dependency-path: docs/requirements.txt
|
cache-dependency-path: docs/requirements.lock
|
||||||
|
|
||||||
- name: Install MkDocs dependencies
|
- name: Install MkDocs dependencies
|
||||||
run: python -m pip install -r docs/requirements.txt
|
run: python -m pip install -r docs/requirements.lock
|
||||||
|
|
||||||
|
- name: Test public documentation boundary
|
||||||
|
run: python scripts/test-verify-public-docs.py
|
||||||
|
|
||||||
|
- name: Test current authentication documentation
|
||||||
|
run: |
|
||||||
|
python scripts/verify-auth-docs.py auth
|
||||||
|
python scripts/verify-auth-docs.py dwh
|
||||||
|
python scripts/test-verify-auth-docs.py auth
|
||||||
|
python scripts/test-verify-auth-docs.py dwh
|
||||||
|
|
||||||
- name: Build documentation
|
- name: Build documentation
|
||||||
# Some documented source files intentionally live outside docs/.
|
run: |
|
||||||
run: mkdocs build
|
mkdocs build --strict
|
||||||
|
python scripts/verify-public-docs.py
|
||||||
|
|
||||||
- name: Publish generated site to the pages branch
|
- name: Publish generated site to the pages branch
|
||||||
working-directory: site
|
working-directory: site
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ deploy/secrets/*
|
|||||||
# Per-installation configuration generated by `tht setup` (examples stay tracked).
|
# Per-installation configuration generated by `tht setup` (examples stay tracked).
|
||||||
deploy/*/thothii-installation.yaml
|
deploy/*/thothii-installation.yaml
|
||||||
deploy/*/operator.env
|
deploy/*/operator.env
|
||||||
|
deploy/*/auth/
|
||||||
deploy/*/generated/
|
deploy/*/generated/
|
||||||
deploy/*/secrets/*
|
deploy/*/secrets/*
|
||||||
!deploy/*/secrets/.gitkeep
|
!deploy/*/secrets/.gitkeep
|
||||||
|
|||||||
@@ -627,3 +627,28 @@ durante una ripresa, anche se la UI locale corrente cambia.
|
|||||||
**Administrative Page Family** — L'insieme delle cinque Administration Page che condividono shell,
|
**Administrative Page Family** — L'insieme delle cinque Administration Page che condividono shell,
|
||||||
navigazione, tipografia e regole responsive, pur mantenendo contenuti e operazioni specifici:
|
navigazione, tipografia e regole responsive, pur mantenendo contenuti e operazioni specifici:
|
||||||
Workspace, Evidence, Memory, Database e Pi.
|
Workspace, Evidence, Memory, Database e Pi.
|
||||||
|
|
||||||
|
## Installazione
|
||||||
|
|
||||||
|
**Manual standalone installation** — Una copia di ThothII predisposta per l'uso autonomo da una
|
||||||
|
persona che possiede il computer, con una Full Thoth Shell e servizi applicativi locali. La
|
||||||
|
procedura non implica che DWH o provider LLM siano locali o disponibili offline.
|
||||||
|
|
||||||
|
**Installation bootstrap** — L'insieme delle attività iniziali che rende disponibile una
|
||||||
|
installazione manuale: verifica dell'host, generazione della configurazione, predisposizione
|
||||||
|
delle credenziali protette e avvio dei servizi. Non è un installer dell'applicazione.
|
||||||
|
|
||||||
|
**Installation preparation** — La predisposizione dei documenti che descrivono i workspace
|
||||||
|
e i parametri dell'installazione, prima di applicarli. Permette all'operatore di raccogliere
|
||||||
|
e correggere le informazioni senza avviare l'applicazione.
|
||||||
|
|
||||||
|
**Installation validation** — La verifica ripetibile della completezza e coerenza dei
|
||||||
|
documenti e delle precondizioni di un'installazione. Distingue ciò che è stato verificato
|
||||||
|
da ciò che richiede un'applicazione già avviata.
|
||||||
|
|
||||||
|
**Installation execution** — L'applicazione dei documenti verificati per predisporre e
|
||||||
|
avviare ThothII. Non raccoglie nuovi parametri dall'operatore durante l'esecuzione.
|
||||||
|
|
||||||
|
**Platform acceptance** — La verifica che una Manual standalone installation possa essere
|
||||||
|
predisposta e avviata su una specifica combinazione di sistema operativo, architettura e runtime,
|
||||||
|
distinta dalla verifica funzionale del collegamento a DWH e provider LLM.
|
||||||
|
|||||||
@@ -1,704 +1,148 @@
|
|||||||
# ThothII — Project State
|
# Project state
|
||||||
|
|
||||||
Last updated: 2026-09-14.
|
Updated: 2026-10-06. This is a current snapshot, not a release diary. Stable commands
|
||||||
|
and invariants are in [AGENTS.md](AGENTS.md); prior snapshots remain in Git.
|
||||||
This file is the short operational snapshot. Stable commands and the architecture mental model
|
|
||||||
live in `AGENTS.md`; current design and runtime contracts live under `docs/architecture/`,
|
## Current contracts
|
||||||
`docs/contracts/`, `docs/adr/`, and `docs/evidence.md`. Superseded plans and reports are
|
|
||||||
available from Git history rather than duplicated in the working tree.
|
- Document-first installation ticket #43 provides offline `tht workspace prepare`
|
||||||
|
and `tht workspace validate` through a native two-executable bundle. Build and
|
||||||
The guarded server migration from a legacy checkout to the schema-v2 installation, Gitea source,
|
test instructions are in [the host CLI guide](tools/tht/README.md). Local validation
|
||||||
Authentik, internal catalog/embedding services, and the PSD workspace repository is documented in
|
reuses runtime workspace/catalog parsers and explicitly defers runtime Evidence,
|
||||||
`docs/operations/server-upgrade-gitea-workspace-v2.md`. Treat its operator gates and rollback
|
database binding and readiness checks. Ticket #44 adds `tht installation prepare`,
|
||||||
requirements as mandatory; do not replace the running server stack in place.
|
explicit `installation credentials`, and `installation validate --workspaces PATH`
|
||||||
|
for protected application documents, canonical model settings and schema-v1
|
||||||
## Session review layout deployed — 2026-09-14
|
database bootstrap inputs. These commands do not start services or import Catalog
|
||||||
|
bindings. Ticket #45 adds host `installation preflight` and `installation plan`
|
||||||
Session-only dialogs now use the visible app bounds: artifact/column review grows
|
with release/image checks, canonical external diagnostics and private input seals;
|
||||||
up to 80rem wide and the available height; short confirmations grow to 40rem.
|
see [the preflight reference](docs/install/installation-preflight.md).
|
||||||
Existing primary actions appear above and below session forms and review content,
|
Ticket #46 adds the maintainer release producer and the first public
|
||||||
with shared handlers, validation and pending state. Stop/delete focus Cancel;
|
[Linux amd64 prerelease](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.1),
|
||||||
rename focuses the name field. Administration surfaces are unchanged. The activity
|
with Docker Hub core/frontend images and a downloadable native operator bundle.
|
||||||
shortcut is relabelled To Administration / Vai all’Amministrazione, retaining its
|
See [publication instructions](docs/install/publishing-images.md) and
|
||||||
workspace-management destination. 778 frontend tests, five responsive browser
|
[verification evidence](docs/reports/2026-09-28-installation-prerelease.md).
|
||||||
scenarios, typecheck, translations and the production build passed. The owner
|
Ticket #47 delivers `installation apply --plan PATH`: fresh checks, immutable
|
||||||
authorized deployment and the server frontend was recreated at 18:09 CEST with tag `b1723c34-session-dialogs-20260914`. Frontend is healthy,
|
pulls, local operator UID, resumable volume initialization, Catalog/Memory migrations
|
||||||
Omics serves the new assets, and doctor passes 13/13 checks. Core and Omics web
|
and service/authentication health. Tests cover the public native command with closed
|
||||||
were not restarted. See DESIGN.md for the layout contract and
|
stdin and Linux volume/private-secret behavior using published images. Platform success
|
||||||
`docs/reports/2026-09-14-session-dialogs-release.md` for provenance and rollback.
|
explicitly leaves workspace readiness false. The current
|
||||||
|
[preview.5 release](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.5)
|
||||||
## Session composer and empty Memory fix deployed — 2026-09-14
|
publishes amd64/arm64 images and native bundles. Its unmodified arm64 archive passed
|
||||||
|
apply/retry, UI/admin login and live user revocation in a Linux consumer without host
|
||||||
The embedded shell now caps its height at the portal mount height, keeping steering
|
language runtimes; see [verification evidence](docs/reports/2026-10-06-installation-apply.md).
|
||||||
and Stop & save visible. Empty authoritative Memory archives return zero results
|
Ticket #48 now adds authenticated binding import after platform health: exact prepared
|
||||||
without requiring embedding/BM25; SQL-rule embedding is lazy and shared. The live
|
repository verification, ordinary local admin login/CSRF, existing encrypted secret
|
||||||
empty PSD archive reproduces 503 with the current image and succeeds with the
|
storage, optimistic versions and container-side Catalog connection tests. Durable
|
||||||
candidate. 54 Memory tests, 90 frontend tests, five browser scenarios and both image
|
Catalog import receipts survive administrative deletion; reruns stop on divergence.
|
||||||
builds passed. The owner authorized the restart and core/frontend were recreated on
|
Source/native command, authenticated client, concurrent/recovery and real PostgreSQL
|
||||||
2026-09-14 at 17:18 CEST with tags `49333a2d-session-memory-fix`, from code committed
|
tests cover this increment. These changes are not included in published preview.5.
|
||||||
as `d6cdffea`. Both are healthy; production Memory search returns `[]`, Omics serves
|
Ticket #49 adds existing durable Catalog Sync Runs and preprocessing to apply,
|
||||||
the corrected CSS, native doctor passes 13/13 checks, and admissions are reopened.
|
preserving human review (exit 3), curated content and Memory. Named one-shot checks
|
||||||
Session inventory is preserved. Backups and rollback images are retained. Native
|
cover workspace diagnostics, workflow configuration and Pi/default-model smoke.
|
||||||
CLI diagnostics must run as installation owner UID 10001 with access to Compose;
|
Reports distinguish platform, binding, workspace readiness and manual functional
|
||||||
see `docs/reports/2026-09-14-session-layout-memory-fix.md` for exact commands and
|
acceptance. This increment also requires a later release than preview.5.
|
||||||
the remaining interactive browser acceptance.
|
Ticket #50 adds an explicit `prepare-source-installation.mjs` producer from an
|
||||||
|
isolated committed worktree. Source bundles pin local application image IDs and
|
||||||
## Full/embedded shell and bilingual interface
|
upstream Docker Hub digests; the same native plan/apply path verifies provenance,
|
||||||
|
shares journal/locks and never falls back to a build. Ticket #51 adds guarded
|
||||||
Full/embedded shell, EN/IT UI, immutable session interaction language, dark theme,
|
interrupted preprocessing recovery, fencing of delayed/orphan workers and preserved
|
||||||
fullscreen and full-mode logout are implemented. The local Mac descriptor explicitly
|
pending schema review even during binding retry. Real-host
|
||||||
sets `shell.mode: full` and `shell.defaultLocale: en`; the native `tht` and local
|
acceptance and curated examples remain pending. Earlier previews are superseded
|
||||||
core/frontend images were updated on 2026-09-13. Omics uses embedded with server-side
|
for platform apply; no complete installer/OS acceptance is claimed.
|
||||||
identity verification and a replaceable presentation-only PortalAdapter; this does
|
|
||||||
not mean this branch was verified on the production server. Its changes are
|
- React supports full/embedded rendering independently of local/OIDC/upstream auth,
|
||||||
in Omics commit `95154e1`; production deployment remains pending.
|
with EN/IT UI and immutable session interaction language. See
|
||||||
See `docs/operations/shell-and-localization.md` for integration and installation
|
[application shell](docs/architecture/application-shell.md) and
|
||||||
instructions and `docs/reports/2026-09-13-full-shell-implementation.md` for tests,
|
[localization](docs/operations/shell-and-localization.md).
|
||||||
independent reviews, local browser checks and rollback details.
|
- PostgreSQL Metadata Catalog owns database identity, binding, schema, descriptions,
|
||||||
|
sensitivity and relationships for all core consumers. Workspace schema v4 contains
|
||||||
### Documentation handoff before branch closure — 2026-09-13
|
identity and optional Evidence only. Installation schema v2 is the authored model
|
||||||
|
catalog source. See [overview](docs/architecture/overview.md) and
|
||||||
Current rendering architecture is in `docs/architecture/application-shell.md`;
|
[model configuration](docs/general/pi-configuration.md).
|
||||||
the exact portal identity/proxy contract is in `docs/install/authentication-upstream.md`.
|
- The harness owns workflow persistence; chat is not the durable session record.
|
||||||
`docs/operations/server-codex-handoff.md` is the current server delivery/deploy
|
Memory uses PostgreSQL authority and derived Qdrant dense/BM25 search. Editable
|
||||||
runbook, including Omics source integration from GitHub, configuration, tests and
|
Evidence has local archive authority and manual consolidation. File save, search
|
||||||
rollback. It supersedes the earlier Omics repository-relay instructions. The acceptance matrix is
|
activation and Git publication have distinct outcomes. See
|
||||||
`docs/testing/authentication-manual-acceptance.md`. README, documentation navigation,
|
[Memory](docs/gestione-memory.md), [Evidence](docs/contracts/curated-evidence-v4.md)
|
||||||
user/installation/authentication guides and descriptor examples point to these
|
and [consolidated release evidence](docs/reports/knowledge-archives-release.md).
|
||||||
paths. Local examples explicitly use full/en; the projected server example is
|
- Reference preprocessing must not clear Memory. Use the installation-scoped
|
||||||
for standalone OIDC, not Omics upstream. No runtime configuration or deployment
|
`tht --installation /absolute/path/thothii-installation.yaml workspace preprocess run`
|
||||||
was changed by that documentation pass. The 2026-09-14 delivery is prepared for
|
and its [contract](docs/contracts/workspace-preprocessing-cli.md).
|
||||||
promotion to main; the actual merge is recorded in Git. PSD acceptance remains pending.
|
- DWH sessions are read-only. SSH tunnels support database-management diagnostics
|
||||||
|
and metadata synchronization, not NL→SQL session creation; use direct or REST
|
||||||
### Navigation readiness and session accordions — 2026-09-13
|
transport for sessions.
|
||||||
|
|
||||||
The Workspace navigation button now carries an accessible green/red readiness
|
## Installation and workspace boundaries
|
||||||
dot instead of a separate text row. Green requires a selected workspace and a
|
|
||||||
successful, current `ready` response; checking, unavailable and other states are
|
Fresh standalone installations follow the document-first procedures in
|
||||||
red, with the state exposed through the tooltip and accessible description.
|
[Italian](docs/install/standalone-manual-it.md) or
|
||||||
The backend readiness gate is unchanged.
|
[English](docs/install/standalone-manual-en.md). The guides retain a separate manual
|
||||||
|
source path; do not mix its setup commands with a released-bundle installation.
|
||||||
Active sessions (non-archived) and Archive both start collapsed. Their adjacent
|
The [Compose reference](docs/operations/compose-reference.md) is for maintainers,
|
||||||
headers are the only visible content below the scope tabs: no Sessions heading
|
not another quick start. Document-first apply runs Catalog and Memory migrations
|
||||||
or external selection toolbar. Each nonempty panel owns its Select all and
|
before bringing up application services.
|
||||||
bulk-delete controls, scoped to that list and preserving the other's selection.
|
|
||||||
As of 2026-09-14, only one section can be open at a time, and either can be
|
Descriptors, authentication, provider credentials, certificates and runtime bindings
|
||||||
collapsed. Empty lists show only "No sessions yet." The open section uses the
|
stay in protected installation-local paths. Do not copy secrets into examples or
|
||||||
remaining sidebar height, with scrolling content capped at `min(18rem, 35dvh)`. The mobile
|
workspace Git. Legacy runtime snapshots may use absolute paths and protected
|
||||||
navigation dialog also provides a bounded height. Keyboard controls and labels
|
`harness/.env`; do not silently relocate them.
|
||||||
are retained. See `DESIGN.md` and `docs/guida-utente.md` for the UI contract.
|
|
||||||
|
PSD authoring is separate at `/Users/mp/projects/tht-workspace-psd`. Its GitHub
|
||||||
Verification: 768 frontend unit tests, 20 browser scenarios (including 80 mocked
|
repository was copied to private Gitea
|
||||||
sessions at 390/1280px), TypeScript and the production frontend build passed.
|
[workspace_psd](https://git.tylconsulting.it/mptyl/workspace_psd), preserving both
|
||||||
Only the Mac frontend was recreated; it is healthy at `127.0.0.1:8080`.
|
branches. It is a copy, not automatic synchronization. Running installations were
|
||||||
Core, catalog, Qdrant and embedding containers were not changed. The prior
|
not repointed to a different workspace remote.
|
||||||
frontend image is retained as
|
|
||||||
`thothii-frontend:before-single-session-accordion-20260914` for rollback.
|
## Recorded deployments and server authority
|
||||||
|
|
||||||
### Current Omics delivery and server handoff — 2026-09-14
|
Use the ordered [server handoff](docs/operations/server-codex-handoff.md) for
|
||||||
|
coordinated ThothII/Omics upgrades. Omics integration uses GitHub
|
||||||
The owner corrected the delivery requirement: Omics is obtained from GitHub,
|
`Dallavilla-Tiziano/omics_portal`, with no Gitea relay prerequisite. Omics uses
|
||||||
not relayed to another repository as part of this deployment. Any optional
|
embedded/upstream identity, not another ThothII OIDC login. Read
|
||||||
server-side repository copy is solely the owner's separate concern. This
|
[upstream authentication](docs/install/authentication-upstream.md) before changes.
|
||||||
supersedes the 2026-09-13 relay agreement, including historical delivery notes
|
|
||||||
in the Omics branch. Do not make another remote publication a prerequisite.
|
Last recorded application deliveries (not a fresh runtime attestation):
|
||||||
|
|
||||||
GitHub branch `codex/thothii-embedded-shell` at
|
- [Session dialogs](docs/reports/2026-09-14-session-dialogs-release.md):
|
||||||
`https://github.com/Dallavilla-Tiziano/omics_portal.git` was reverified at
|
`b1723c34-session-dialogs-20260914`, frontend-only.
|
||||||
`fca10901a73666ca257d8f4cc4b77066295c400a` (functional commit `95154e1`).
|
- [Session layout/Memory fix](docs/reports/2026-09-14-session-layout-memory-fix.md):
|
||||||
The server operator integrates it with the current code in the confirmed Omics
|
`49333a2d-session-memory-fix`, core/frontend.
|
||||||
checkout, normally `/home/chirone/omics_portal`, preserving later server changes.
|
|
||||||
`docs/operations/server-codex-handoff.md` is the authoritative ordered procedure:
|
Keep those reports and rollback instructions while operator gates remain open.
|
||||||
inventory, source verification, native CLI and installation projections,
|
A later deployment does not prove every earlier acceptance item passed.
|
||||||
embedded/upstream auth, Omics templates/static assets/proxy, coordinated rollout,
|
|
||||||
acceptance and rollback. Server deployment and real IdP acceptance remain pending.
|
## Remaining acceptance and design gates
|
||||||
|
|
||||||
## Current product shape
|
- The first installation acceptance uses an ad hoc
|
||||||
|
[Chinook workspace without Evidence](docs/testing/chinook-installation-smoke.md),
|
||||||
### Shared Memory/Evidence typography — 2026-09-13
|
backed by a separate local PostgreSQL test container. Its fixture import,
|
||||||
|
read-only credentials, offline validation and platform apply were verified; binding
|
||||||
Both detail readers now share Manrope and fixed reading roles: 24px card title,
|
import, workspace readiness and a human-reviewed question remain pending. Evidence
|
||||||
20px section headings, 16px/1.65 narrative text, and 14px metadata/code. Authored
|
acceptance and the three curated examples are separate later work.
|
||||||
Markdown subheadings remain subordinate to field headings; inline/fenced code no
|
- Fresh-machine installation acceptance, including real DWH/model endpoints, remains
|
||||||
longer shrinks cumulatively. Full-width layout, paragraph separation and isolated
|
a separate operator exercise, ordered Windows/WSL2, then Omarchy, then macOS.
|
||||||
FAKE examples are retained. All 762 frontend tests and 18 browser scenarios pass,
|
- Real IdP/portal login, logout, embedded interaction and PSD semantic acceptance
|
||||||
including computed typography checks at 390/1280/2400px; typecheck, i18n and Docker
|
follow the [manual matrix](docs/testing/authentication-manual-acceptance.md) and
|
||||||
build pass. Only Mac frontend was recreated: `87fca0dc5e19`, image `19f1704b6bb2`,
|
delivery reports; synthetic tests do not close them.
|
||||||
healthy. Core and data services are unchanged. Rollback image:
|
- [Security hardening](docs/plans/2026-09-08-security-hardening-prd.md) is a draft.
|
||||||
`thothii-frontend:before-knowledge-typography-20260913`. See
|
Revalidate SEC01–12 and obtain design approval before implementation or real
|
||||||
`docs/reports/2026-09-13-knowledge-typography.md`. No PSD/Omics deployment.
|
server/IdP/DWH mutation.
|
||||||
|
- Optional NER remains opt-in; labeled Italian quality, benchmark and licensing
|
||||||
### Knowledge reading and isolated fake Memory examples — 2026-09-13
|
acceptance are not implied by document cleanup.
|
||||||
|
- Semantic aliases, value descriptions, synonyms/concepts, dialect and multi-schema
|
||||||
Memory/Evidence details now use all available width, with display-only paragraph
|
extensions remain explicit design work. Current sensitivity delivery follows the
|
||||||
splitting for long plain prose and preserved code/Markdown/source data. Evidence
|
Catalog contract; additional policies require their own acceptance.
|
||||||
provenance renders Markdown; copy controls are accessible two-sheet icons.
|
- Legacy database UI fallback (`?db-ui=legacy`, dev/staging) and prototype removal
|
||||||
Memory's separate Formatting examples section contains four FAKE cards (one per
|
remain subject to owner acceptance.
|
||||||
family), automatically expanded for an empty archive. These client-side examples
|
|
||||||
cannot be edited/saved/indexed and are never submitted to the model or Memory API.
|
## Documentation maintenance
|
||||||
No real archive content was changed. 762 tests, 18 browser scenarios, typecheck,
|
|
||||||
i18n and Docker build pass. Only the Mac frontend was recreated: `fc4286b5406d`,
|
MkDocs publishes only 22 product/operator pages and five approved assets.
|
||||||
image `cbe0fe0dce55`, healthy; other services unchanged. Rollback image:
|
Architecture, contracts, ADRs, plans, research, tests and release evidence are
|
||||||
`thothii-frontend:before-knowledge-reading-20260913`. Details in
|
excluded from HTML and search. The repository itself is public: editorial exclusion
|
||||||
`docs/reports/2026-09-13-knowledge-reading.md`; no PSD/Omics deployment.
|
is not confidentiality.
|
||||||
|
|
||||||
### Unified Session entry and complete tab borders — 2026-09-13
|
The [cleanup record](docs/maintenance/2026-09-15-documentation-cleanup.md) records
|
||||||
|
retired sources and retained gates. Main contains source; Actions generates the
|
||||||
The sidebar has one Session/Sessione button: return to the current unfinished
|
`pages` branch. The live site requires the separate explicit deployment described
|
||||||
session (including pending creation) without resetting/reconnecting it; otherwise
|
in [public manual publication](docs/operations/public-docs-publication.md).
|
||||||
prepare a new question with existing readiness and dirty-edit guards. Creation
|
|
||||||
still requires submitting a question. A cold document panel is not a running session.
|
|
||||||
Session tabs now have 11px horizontal/3px vertical padding, at least 38px height,
|
|
||||||
and matching 1px borders on every side (gray inactive, red active), with no shared
|
|
||||||
baseline or overlapping bottom border. This supersedes the earlier border removal.
|
|
||||||
757 frontend tests, 15 browser scenarios, typecheck, i18n and Docker build pass.
|
|
||||||
Mac frontend `2844778d311c`, image `d58dccfee3f9`, is healthy; only that service
|
|
||||||
was recreated. Core/data services are unchanged, with no Omics or server deploy.
|
|
||||||
Rollback image: `thothii-frontend:before-session-navigation-20260913`.
|
|
||||||
|
|
||||||
### Login copy and language-selector focus — 2026-09-13
|
|
||||||
|
|
||||||
Removed the redundant login eyebrow/icon and installation-account explanation;
|
|
||||||
the main sign-in heading remains. The full-header language select no longer
|
|
||||||
shows an outer focus ring after pointer interaction; keyboard focus remains
|
|
||||||
visible, including after returning with Tab. EN/IT login and both themes are
|
|
||||||
covered by 36 targeted tests and 14 browser scenarios; typecheck/build pass.
|
|
||||||
Only the Mac frontend was rebuilt/recreated: `204efd40d3eb`, image `7dd0752ff823`,
|
|
||||||
healthy. Other containers are unchanged. Rollback image:
|
|
||||||
`thothii-frontend:before-login-focus-20260913`. No production deployment.
|
|
||||||
|
|
||||||
### Full-header and layout refinements — 2026-09-13
|
|
||||||
|
|
||||||
The owner's four visual adjustments are implemented: full header uses Omics
|
|
||||||
`#CB333B` in both themes with a light complete wordmark/controls; Database status
|
|
||||||
has 16px clearance below its top divider; workspace/model/Done share a compact
|
|
||||||
desktop row; session-scope tabs have no bottom border. Embedded has no extra header.
|
|
||||||
Verified with 71 targeted frontend tests, 11 browser scenarios, typecheck and
|
|
||||||
Docker production build. The Mac frontend was recreated alone and is healthy
|
|
||||||
(`8a1608ad7fc6`, image `a2f489ebe9de`); Core/data-service containers are unchanged.
|
|
||||||
Full/en is retained. Rollback image: `thothii-frontend:before-header-layout-20260913`.
|
|
||||||
See `docs/reports/2026-09-13-header-layout-refinements.md` for validation and rollback.
|
|
||||||
|
|
||||||
### Visual review integrated with the full/embedded shell
|
|
||||||
|
|
||||||
At the owner's request, the seven commits through `a59624a6` from
|
|
||||||
`codex/ui-visual-review` are integrated with the shell/i18n work in this checkout,
|
|
||||||
`codex/prototype-administration-pages`. Both branches started at `2d1b714e`; the
|
|
||||||
first full-shell build omitted that lateral branch and regressed the installed UI.
|
|
||||||
The integrated source retains bundled Manrope, shared type roles, catalog/context
|
|
||||||
alignment, wordmark sizes and composer autosizing alongside full/embedded and EN/IT.
|
|
||||||
|
|
||||||
Local Docker was updated at 12:54 UTC on 2026-09-13: frontend image `605a6e6bba68`,
|
|
||||||
healthy; Core and all data-service containers were unchanged. Mac remains full/en.
|
|
||||||
The immediate pre-merge frontend is retained as
|
|
||||||
`thothii-frontend:before-visual-shell-merge-20260913`.
|
|
||||||
|
|
||||||
Verification: 755 frontend tests, 11 Playwright visual/interaction scenarios at five
|
|
||||||
widths, translation-catalog checks, typecheck and production build. See
|
|
||||||
`docs/reports/2026-09-13-visual-shell-integration.md` for delivery, provenance and
|
|
||||||
rollback details. The separate visual-review worktree and its rollback images are
|
|
||||||
retained. No merge to `main`, push or production deployment is part of this delivery.
|
|
||||||
|
|
||||||
Gitea #28–#31 follow-up is implemented in this checkout: Workspace's four tabs,
|
|
||||||
Database list-first entry without the preparation footer, full-height Pi instructions
|
|
||||||
with installation-host OS selection, and short Admin navigation labels. Core and
|
|
||||||
session behavior are retained. At the owner's request, these changes were rebuilt into
|
|
||||||
local Docker on 2026-09-12 at 18:31 UTC. Core/frontend are healthy and the UI at
|
|
||||||
`http://127.0.0.1:8080` serves the updated bundle. The host projection now supplies
|
|
||||||
`THT_HOST_PLATFORM=darwin`, so Pi selects macOS rather than the container's Linux OS.
|
|
||||||
Persistent dependency containers and volumes were unchanged. Rollback images are tagged
|
|
||||||
`thothii-core:before-admin-28-31-20260912` and
|
|
||||||
`thothii-frontend:before-admin-28-31-20260912`. See
|
|
||||||
`docs/reports/2026-09-12-admin-issues-28-31.md` for verification and deployment details.
|
|
||||||
|
|
||||||
The latest context-shelf A and five Administration pages are implemented locally.
|
|
||||||
At the owner's request, local Docker project `thothii-18998cca7b0a` was rebuilt and
|
|
||||||
its core/frontend recreated on 2026-09-12. The real UI at `http://127.0.0.1:8080`
|
|
||||||
serves shelf A; both services and their existing dependencies are healthy.
|
|
||||||
Runtime model projections were regenerated as schema v2 with the single
|
|
||||||
`zai/glm-5.3` interaction default. Persistent services/volumes were not recreated.
|
|
||||||
The local launcher `/private/tmp/thothii-memory-preview.sh` now adds
|
|
||||||
`/private/tmp/thothii-context-a.compose.yaml` last, building from this checkout
|
|
||||||
instead of the earlier Memory worktree. Previous images are retained under
|
|
||||||
`thothii-core:before-context-a-20260912` and
|
|
||||||
`thothii-frontend:before-context-a-20260912`. Remote server deployment remains pending.
|
|
||||||
Core/session behavior is retained; one independently remembered workspace/model
|
|
||||||
pair controls both Core and Admin. Unsaved Admin changes block navigation and
|
|
||||||
context changes; operation activity locks the selectors. See
|
|
||||||
`docs/reports/2026-09-12-context-shelf-a-implementation.md` for verification and the
|
|
||||||
remaining server/Omics integration gate. Prototype alternatives remain untouched.
|
|
||||||
|
|
||||||
ThothII is a human-in-the-loop datamart builder with three independently built layers:
|
|
||||||
|
|
||||||
```text
|
|
||||||
frontend (React/SSE) → backend (Fastify) → pi --mode rpc → tht/harness → DWH (read-only)
|
|
||||||
```
|
|
||||||
|
|
||||||
The harness owns the deterministic eight-phase NL→SQL workflow and all session persistence.
|
|
||||||
The backend remains a process/RPC/SSE bridge for sessions and now also owns an isolated PostgreSQL
|
|
||||||
metadata catalog for administrative database configuration. The frontend renders the review gates
|
|
||||||
and keeps the live transcript in memory. See
|
|
||||||
`docs/architecture/components.md` for the detailed component and data-flow map.
|
|
||||||
|
|
||||||
## Memory M1–M3, Evidence E1–E3 and joint workflow repair X1 implemented
|
|
||||||
|
|
||||||
Browser authorization now derives permissions from validated session roles using the current
|
|
||||||
catalog. This fixes Memory/Evidence navigation remaining disabled for administrators whose
|
|
||||||
remembered login predates those permissions; refreshing the page loads the updated permissions.
|
|
||||||
|
|
||||||
The owner requested two independent administration projects: Memory management and Evidence
|
|
||||||
management. Their navigation entries must sit immediately after Database management, as peers;
|
|
||||||
neither page belongs to Database management. Both require complete browsing, filtering, and CRUD
|
|
||||||
without an active core session. Shared requirements and the two project briefs are linked from
|
|
||||||
`docs/plans/2026-09-08-memory-evidence-administration.md`. Memory administration is implemented;
|
|
||||||
Evidence administration is implemented through external file editing and explicit consolidation.
|
|
||||||
Evidence editing requires an explicit evolution of the current authoring/publication contract.
|
|
||||||
The M1 specification is at `docs/plans/2026-09-08-memory-m1-spec.md` and published as
|
|
||||||
[M1 — Archivio autorevole e amministrazione delle Memory Card](https://git.tylconsulting.it/mptyl/ThothII/issues/27)
|
|
||||||
with the `ready-for-agent` and `enhancement` labels.
|
|
||||||
It covers the authoritative store, administrative CRUD, projection recovery, and current
|
|
||||||
Memory/exemplar producer integration. Its accepted test boundaries are the public harness
|
|
||||||
service, Fastify APIs, and the AppShell page, joined by a focused real-stack browser path.
|
|
||||||
The owner confirmed those boundaries and authorized publication on 2026-09-08.
|
|
||||||
M1 is implemented locally: PostgreSQL authority in `thoth_memory`, versioned installation
|
|
||||||
migrations, admin CRUD for all four families, structured dependencies and links, explicit
|
|
||||||
projection recovery, verified recall and current workflow producers. The page requires no
|
|
||||||
active session or DWH binding. The existing `catalog-migrate` preparation service now runs
|
|
||||||
Memory migrations as well. Existing installations need that preparation before using M1;
|
|
||||||
the initial implementation did not deploy or migrate the owner's stacks.
|
|
||||||
The integrated browser check passed with real authentication, Fastify, ThtRunner, harness,
|
|
||||||
PostgreSQL and Qdrant; embeddings were deterministic and unrelated Pi/session activity used
|
|
||||||
test fixtures. See `docs/plans/2026-09-08-memory-m1-validation.md` for results and commands.
|
|
||||||
M2 is implemented locally: Memory dense/BM25 fusion, physical and business scope filters,
|
|
||||||
bounded outgoing-link expansion and joint ranking, all resolved against current PostgreSQL
|
|
||||||
authority. Migration `002_hybrid_projection.sql` makes old dense projections pending until
|
|
||||||
explicit retry/rebuild; Reference remains separate. The real retrieval check uses the configured
|
|
||||||
`qwen3-embedding:0.6b` model, a separate Ollama process with a read-only model-volume mount,
|
|
||||||
and isolated PostgreSQL/Qdrant resources. See `docs/plans/2026-09-09-memory-m2-validation.md`.
|
|
||||||
M3 is implemented: editable F8 summary grounded in effective approved decisions, explicit
|
|
||||||
updates with concurrent-edit protection, selected-card/link transactions and durable review
|
|
||||||
receipts. Finalization no longer saves exemplars implicitly. SQL rules and explained errors
|
|
||||||
are consulted in the existing F4/F6/F7 gates. Successful Catalog physical synchronization
|
|
||||||
performs dependency cleanup, preserving the original removals for recovery across restarts.
|
|
||||||
Migration `003_review_receipts.sql` is required. Validation includes a real GLM 5.3 generation
|
|
||||||
case against synthetic PostgreSQL data; see `docs/plans/2026-09-09-memory-m3-validation.md`.
|
|
||||||
Evidence administration and the joint X1 conflict-repair increment are now implemented.
|
|
||||||
The same local preview was subsequently rebuilt with M3 and migration 003 applied.
|
|
||||||
Core and frontend now include the final Memory review and physical dependency cleanup.
|
|
||||||
On 2026-09-09, at the owner's request, the local PSD Docker installation
|
|
||||||
`thothii-18998cca7b0a` was updated from this worktree. Core/frontend images were rebuilt,
|
|
||||||
Catalog and Memory migrations completed, and all five services became healthy. The UI is at
|
|
||||||
`http://127.0.0.1:8080`, using the existing local authentication and persistent volumes.
|
|
||||||
The `psd-clinical` authoritative Memory archive is initially empty (no legacy import).
|
|
||||||
The existing installation configuration remains in `/Users/mp/projects/ThothII/deploy/psd/`;
|
|
||||||
`/private/tmp/thothii-memory-preview.sh` invokes its Compose files with a final build-context
|
|
||||||
and migration-command override from this worktree. A future build from the main checkout
|
|
||||||
will use that checkout's code, so retain the worktree override until the changes are integrated.
|
|
||||||
Memory revision history and compatibility with existing development sessions are not requirements.
|
|
||||||
The agreed Memory scope includes reusable domain clarifications, SQL construction rules, solved
|
|
||||||
questions, and explained, approved mistakes to avoid. This extends the current runtime's
|
|
||||||
`concept_clarified`-only reusable Memory contract. The owner also approved an editable final summary
|
|
||||||
for proposed additions/updates and Memory consumption in the relevant existing review gates.
|
|
||||||
Further agreed behavior includes persistent corrections for Memory/Evidence conflicts through
|
|
||||||
explicit choices, deletion of Memory with invalid dependencies after successful physical schema
|
|
||||||
synchronization, and bounded functional/regression tests instead of a general quality benchmark.
|
|
||||||
In-house Memory evolution is approved, including hybrid Qdrant retrieval and explicit card links
|
|
||||||
traversed in core, without a dedicated graph database. Both capabilities belong to the current
|
|
||||||
scope. PostgreSQL is the agreed authority for Memory Cards, links, and schema dependencies;
|
|
||||||
Qdrant is a rebuildable index. Links are reviewed with cards and editable in Administration;
|
|
||||||
deleting a card removes its incident links while preserving the other cards. The accepted,
|
|
||||||
implemented architecture is recorded in
|
|
||||||
`docs/adr/0018-use-postgres-for-memory-and-qdrant-for-retrieval.md`.
|
|
||||||
For Evidence administration, Q12 rejects a separate editorial publication workflow.
|
|
||||||
The final R0 direction uses external editors and a manual consolidation command that
|
|
||||||
validates structure, reports required corrections, updates derived metadata, and
|
|
||||||
activates the local Evidence index. The operator then checks the diff and runs Git
|
|
||||||
commit/push manually. No watcher, automated Git, or web editor is required.
|
|
||||||
The owner's later simplification
|
|
||||||
instruction removes the requirement to support administrative edits while core work
|
|
||||||
is in progress. Deliberate corrections made by the workflow itself remain supported.
|
|
||||||
The context specialist writes Evidence drafts independently of the installation and
|
|
||||||
without PostgreSQL access; the system refines them and stores them locally for use
|
|
||||||
and maintenance. The revised Q11 recommendation separates external drafts from a
|
|
||||||
durable local canonical file archive, removing automatic commit/push from CRUD.
|
|
||||||
The owner has now accepted local files and requires discoverable, editable Markdown
|
|
||||||
for nontechnical domain specialists, with no JSONL management surface. Editors on
|
|
||||||
Mac/PC or vim/nano on the server are the chosen R0 editing surface. Evidence
|
|
||||||
management keeps browsing/filtering/detail and clearly identifies the persistent
|
|
||||||
working tree, each Markdown file's actual host path, and the manual commands.
|
|
||||||
E1 implements editable Curated Evidence v4, deterministic legacy conversion, persistent
|
|
||||||
local files and a consolidation API with immutable candidates, manual provenance,
|
|
||||||
deletion records and recoverable activation. E2 connects its installed command, runtime source
|
|
||||||
selection and administration page. The operator completes Git steps manually.
|
|
||||||
All 35 PSD units were converted on an isolated copy with identical IDs and typed content.
|
|
||||||
Tests exercise visible edits through normalization, indexing and recall with real Qdrant;
|
|
||||||
see `docs/plans/2026-09-09-evidence-e1-validation.md` and
|
|
||||||
`docs/contracts/curated-evidence-v4.md`. E2 is now running on the local Docker preview:
|
|
||||||
all 35 PSD units were converted and indexed through the installed command. The editable
|
|
||||||
host archive is `/Users/mp/projects/ThothII/deploy/psd/evidence-registry/repo/psd-clinical/evidence`.
|
|
||||||
The original registry-volume checkout and original author repository were retained.
|
|
||||||
The installation descriptor now includes `workspace-bindings.yaml` and `evidence-host.yaml`
|
|
||||||
so native maintenance uses the same volumes and checkout as the preview. Descriptor backup:
|
|
||||||
`/private/tmp/thothii-installation-before-e2.yaml`; previous native binary: `/private/tmp/tht-before-e2`.
|
|
||||||
The launcher remains `bash /private/tmp/thothii-memory-preview.sh`; its worktree build override
|
|
||||||
is still required until integration. Runtime lease filenames now include rendered bytes so
|
|
||||||
upgrading the Evidence renderer does not collide with old immutable configs; Catalog
|
|
||||||
input fingerprints and readiness are unchanged. See `docs/plans/2026-09-09-evidence-e2-validation.md`.
|
|
||||||
E3 adds explicit source acquisition/refinement and durable comparisons in Evidence management.
|
|
||||||
Local drafts go in `evidence/incoming/`; original local documents and configured HTTP/S3
|
|
||||||
sources are reacquired only by **Import or refresh sources** or installed
|
|
||||||
`tht workspace evidence refresh --workspace <id>`. Keep/replace decisions, including the
|
|
||||||
native `workspace evidence decide` command, activate through the existing archive/index
|
|
||||||
path and have durable retry state. Acquired source versions and remote provenance stay
|
|
||||||
local; old documentary lineage can coexist with current manual declarations.
|
|
||||||
The installed preview's 35 PSD sources were verified unchanged with no new proposals.
|
|
||||||
The previous native CLI is backed up at `/private/tmp/tht-before-e3`.
|
|
||||||
See `docs/plans/2026-09-09-evidence-e3-validation.md` for tests and validation limits.
|
|
||||||
X1 adds `reviewer_archive_repair`: closed alternatives with complete before/after content,
|
|
||||||
explicit rejection/reformulation, admin-only application, durable session receipts and
|
|
||||||
retry of saved but inactive corrections. The coordinator uses the canonical Memory and
|
|
||||||
Evidence services; phase approval remains separate. Migration `004_archive_repairs.sql`
|
|
||||||
is required. See `docs/contracts/archive-repair.md` for authorization and recovery limits.
|
|
||||||
X1 validation is recorded in `docs/plans/2026-09-09-archive-repair-x1-validation.md`:
|
|
||||||
both archives were corrected and retrieved through the actual CLI with real PostgreSQL
|
|
||||||
and Qdrant; desktop/mobile widget behavior and permission failures were verified separately.
|
|
||||||
The local preview images include X1 and migration 004 is applied. Follow-up technical
|
|
||||||
acceptance passed with configured GLM 5.3 generating closed conflict alternatives and
|
|
||||||
the chosen Memory correction persisted and retrieved. An authenticated browser test
|
|
||||||
also verified both administration pages, navigation order, Evidence filtering, workspace
|
|
||||||
404s, desktop/mobile layout, and Evidence survival after Memory deletion. All approved
|
|
||||||
technical increments/checks are complete. A real PSD domain-conflict session remains
|
|
||||||
the reviewer's semantic acceptance check; automated cases did not modify PSD knowledge.
|
|
||||||
The joint browser inspection also fixed mobile archive navigation: below 768px,
|
|
||||||
Memory and Evidence keep the full content width and open navigation in the shared
|
|
||||||
accessible dialog. Desktop retains its sidebar; the local frontend image includes this fix.
|
|
||||||
The owner accepted the remaining simplifications and requested explicit clarification
|
|
||||||
of the core format change and the simple terminal-based Git check. E1 must adapt
|
|
||||||
the Evidence parser, renderer, authoring, validation, and normalization; convert
|
|
||||||
existing files and reindex; and verify that visible edits reach core consumption.
|
|
||||||
Preserve the internal typed model where possible. This precedes the administrative
|
|
||||||
page and is not merely a presentation change. Human inspection uses normal Git
|
|
||||||
status and optional line-level diff commands; no custom diff viewer or mandatory
|
|
||||||
double review is required.
|
|
||||||
The suggestion of making PostgreSQL the Evidence authority was withdrawn after this
|
|
||||||
clarification; it was never implemented or accepted as a replacement for Q11.
|
|
||||||
Q13 keeps manual corrections active when updated sources contradict them, until an
|
|
||||||
administrator resolves the comparison; deleted Evidence must not be regenerated
|
|
||||||
automatically. Q14 allows direct manual creation and records a manual declaration
|
|
||||||
as the current source, preserving any original document as distinct provenance.
|
|
||||||
Q15 refreshes external sources only on explicit administrator request; normal saves
|
|
||||||
and lookups do not reacquire them. These decisions, now implemented through E1–E3, are recorded in
|
|
||||||
`docs/adr/0019-author-evidence-in-app-with-automatic-activation.md`.
|
|
||||||
The decision-by-decision review is recorded in
|
|
||||||
`docs/plans/2026-09-08-memory-evidence-simplification-review.md`; it distinguishes the
|
|
||||||
new constraints from the revised technical recommendations. It also specifies a
|
|
||||||
sequential save with minimal durable retry state and direct Memory cleanup after
|
|
||||||
successful schema synchronization, without new queues or event infrastructure.
|
|
||||||
The delivery order remains Memory, Evidence, and persistent conflict repair between
|
|
||||||
both modules. Local curated Evidence must survive preprocessing Clear and be backed
|
|
||||||
up as primary data; the Qdrant projection remains rebuildable.
|
|
||||||
No runtime gate change or administrative page is implemented yet.
|
|
||||||
|
|
||||||
## Evidence restructuring — accepted
|
|
||||||
|
|
||||||
The evidence restructuring and PSD migration completed real acceptance on 2026-08-25.
|
|
||||||
|
|
||||||
- The curated PSD revision contains 35 approved Evidence units and 60 review items.
|
|
||||||
- The PSD authoring repository publishes all 35 units using Curated unit schema v3. Its table-free
|
|
||||||
presentation uses hidden canonical metadata, wrapping Markdown scope lists, list-based enum
|
|
||||||
values, and collapsed technical provenance. Long domain rules now have a deterministic
|
|
||||||
human-readable presentation while retaining their exact canonical text for vector ingestion.
|
|
||||||
`tht evidence migrate <workspace-root>` performs the deterministic v1/v2 upgrade and older-v3
|
|
||||||
presentation rewrite without model calls. The structured-rule PSD rewrite is currently local and
|
|
||||||
pending commit/publication.
|
|
||||||
- The accepted snapshot is
|
|
||||||
`psd-clinical-675990d90eae51da6f2bd51b1ae2609f245772ef-snapshot`.
|
|
||||||
- The active generation is `gen:f968b3bd7a553dbfef3cf47093698f2bc7f95f11`.
|
|
||||||
- Retrieval acceptance reached 20/20 Hit@10.
|
|
||||||
- A real session, `20301df7-cad7-403d-a4c1-9f35c9d07b66`, completed F1–F8 with five
|
|
||||||
receipts, three CTEs, and a final result of 78 patients.
|
|
||||||
- The durable acceptance record is
|
|
||||||
`docs/testing/evidence/evidence-restructuring-psd-acceptance-2026-08-25.md`.
|
|
||||||
|
|
||||||
The canonical authoring, validation, publication, materialization, and preprocessing flow is
|
|
||||||
documented in `docs/evidence.md`. The governing contracts are
|
|
||||||
`docs/contracts/workspace-evidence-v3.md` and
|
|
||||||
`docs/contracts/workspace-preprocessing-cli.md`.
|
|
||||||
The incremental server procedure for the `260906-preprocessing-complete` release is
|
|
||||||
`docs/operations/server-handoff-260906-preprocessing-complete.md`.
|
|
||||||
|
|
||||||
## Workspace preprocessing and configuration
|
|
||||||
|
|
||||||
The native host CLI `tht` is the operator surface. Workspace preprocessing runs through:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
tht --installation /absolute/path/thothii-installation.yaml \
|
|
||||||
workspace preprocess run --workspace <workspace-id>
|
|
||||||
```
|
|
||||||
|
|
||||||
This complete one-shot command uses the profile-gated `workspace-maintenance` service. Partial DWH,
|
|
||||||
schema, Evidence, and vector mutation commands are retired.
|
|
||||||
|
|
||||||
The right Administration sidebar invokes that same operation for the selected workspace. It shows
|
|
||||||
only current readiness or the latest bounded failure diagnostic; there is no preprocessing history.
|
|
||||||
Known non-ready state disables **Session** when it would start a new question,
|
|
||||||
while backend admission remains authoritative.
|
|
||||||
The same control exposes an inline-confirmed **Clear** action to remove replaceable reference
|
|
||||||
vectors, LSH, corpus, and checkpoints while preserving the separate Memory collection. The host CLI
|
|
||||||
equivalent is `workspace preprocess clear`.
|
|
||||||
|
|
||||||
Each workspace now uses `<workspace>-reference` for Schema, relationships, and Evidence and
|
|
||||||
`<workspace>-memory` for `memory` and `solved_question`. Clear and preprocessing own only the former.
|
|
||||||
LSH ownership additionally binds the Catalog database ID and Metadata Content Revision, so derived
|
|
||||||
values cannot be reused across database identities or Catalog revisions.
|
|
||||||
|
|
||||||
Workspace descriptors use schema v4 and contain only workspace identity and optional Evidence.
|
|
||||||
PostgreSQL Metadata Catalog owns database identity, binding, schema, descriptions, sensitivity, and
|
|
||||||
relationships; model, provider, embedding, and vector-store configuration is installation-owned. For
|
|
||||||
PSD, workspace content and runtime roots point to the
|
|
||||||
separate uncommitted repository `/Users/mp/projects/tht-workspace-psd`. Secrets remain outside
|
|
||||||
Git and are supplied only through installation-local protected files.
|
|
||||||
|
|
||||||
## Installation Model Catalog
|
|
||||||
|
|
||||||
`thothii-installation.yaml` schema version 2 is the only operator-authored source for session,
|
|
||||||
metadata-generation, and embedding models. The host `tht` lifecycle validates `modelCatalog` and
|
|
||||||
regenerates the backend catalog, Pi `models.json`/`settings.json`, and Compose override under the
|
|
||||||
installation-local `generated/` directory. Those projections are replaceable runtime adapters:
|
|
||||||
they are not edited, backed up, or treated as configuration.
|
|
||||||
|
|
||||||
Core and Administration now share one canonical `modelCatalog.defaults.interaction` per installation,
|
|
||||||
independent of workspace. Runtime catalog schema v2 contains only `defaultInteraction`; apply the host,
|
|
||||||
backend, and regenerated projections together. Equal legacy defaults normalize on read; conflicting
|
|
||||||
ones require an explicit operator choice. With Admin AI configured, selectable models are the
|
|
||||||
intersection of the Pi and LiteLLM adapters; Core-only installations remain supported without Admin AI.
|
|
||||||
The existing Core and Database controls share the operational selection. Explicit model choices are
|
|
||||||
remembered per authenticated user/application mount in this browser, not in installation settings.
|
|
||||||
Resume uses that selection/default while preserving the historical workspace/revision and manifest.
|
|
||||||
Every model must be manually exercised in both Core and Admin as documented in
|
|
||||||
`docs/general/pi-configuration.md`; validation is not a live model certification.
|
|
||||||
These changes and shelf A are now deployed to local Docker; remote deployment remains pending.
|
|
||||||
|
|
||||||
PSD DeepSeek Pro/Flash now share canonical `deepseek/...` identities across native Pi and LiteLLM,
|
|
||||||
using the existing `DEEPSEEK_API_KEY` bundle entry. Its value was confirmed identical to the working
|
|
||||||
Pi key without exposing it; no secret files were changed. The duplicate `deepseek-metadata` descriptor
|
|
||||||
is removed locally and the tracked example uses the shared provider. `secret_env` overrides legacy
|
|
||||||
Pi auth only inside temporary runtime snapshots and fails closed if the bundle key is missing.
|
|
||||||
The original auth store/history and `zai/glm-5.3` default are preserved. Local Docker projections
|
|
||||||
and core/frontend were updated together on 2026-09-12. Regenerate projections with
|
|
||||||
the matching release for the separate server deployment.
|
|
||||||
|
|
||||||
Provider authentication declares
|
|
||||||
one explicit mode (`secret_env`, `pi_auth`, or `none`); `secret_env` names a protected bundle key.
|
|
||||||
The backend settings store now owns only the selected workspace and thinking level. Existing v1
|
|
||||||
installations use the explicit catalog migration command; schema-v3 workspace descriptors are
|
|
||||||
converted deterministically in their curator-owned repository before commit. Strict runtime loading
|
|
||||||
does not silently infer or merge legacy sources. ADR 0013 and
|
|
||||||
`docs/plans/2026-09-02-installation-model-catalog.md` record the decision and implementation.
|
|
||||||
|
|
||||||
## Database management
|
|
||||||
|
|
||||||
The database, table, and authoritative physical-schema catalog slices are implemented. Database
|
|
||||||
Management now opens the Fleet Ledger presentation by default inside `AppShell`, lists every YAML
|
|
||||||
workspace, creates at most one PostgreSQL database configuration per workspace, edits direct
|
|
||||||
PostgreSQL, REST API, or SSH-tunnel installation bindings, replaces write-only encrypted secrets,
|
|
||||||
and tests supported connector bindings. The surface keeps one responsive AG Grid visible at a time:
|
|
||||||
databases lead to tables, tables lead to columns, and relationships are a sibling database view.
|
|
||||||
Parent navigation remains explicit through the breadcrumb and emphasized back control.
|
|
||||||
|
|
||||||
Selection-scoped operations use one action selector plus an explicit **Run** control; ineligible
|
|
||||||
actions remain visible with their disabled reason, while row-scoped actions stay in the pinned final
|
|
||||||
column. The KPI strip reads installation-wide or selected-database aggregates from
|
|
||||||
`GET /catalog/metrics`. Database configuration, metadata editors, synchronization history,
|
|
||||||
description history, and sensitive-field review/history use the production APIs in right-side
|
|
||||||
drawers rather than prototype fixtures; closing a history drawer does not stop its background run.
|
|
||||||
|
|
||||||
Sensitive-field review is now driven by the versioned local `sensitivity-v4` policy, not by a
|
|
||||||
catalog model. The backend reads selected source tables through read-only, database-specific
|
|
||||||
adapters and makes every `sensitive | non_sensitive` draft decision in the TypeScript
|
|
||||||
`SensitivityClassifier`. A single validated match protects the column. Tables up to 1,000 rows are
|
|
||||||
fully scanned; larger tables use breadth-first 300, 1,000, and text-only 3,000-value targets, with a
|
|
||||||
five-second limit per source query and no global request deadline. Source failures fail the run
|
|
||||||
instead of yielding `unknown`; coverage remains visible separately from the proposal. Draft
|
|
||||||
assessments remain transient until an administrator explicitly saves them. Optional GLiNER2
|
|
||||||
evidence is CPU-only, offline, opt-in, and never replaces the deterministic decision point; see
|
|
||||||
`docs/operations/sensitivity-analysis.md`. The earlier v1 PSD shadow comparison kept NER disabled by
|
|
||||||
default; see `docs/reports/2026-09-02-psd-sensitivity-shadow.md`. The v2 comparison completed all
|
|
||||||
2,275 columns: CPU NER added 18 sensitive proposals and increased warm runtime from 50.1 to 61.3
|
|
||||||
seconds; see `docs/reports/2026-09-03-psd-progressive-sensitivity-shadow.md`.
|
|
||||||
Version 4 excludes declared `bigint` primary-key columns and conventionally named `pk bigint`
|
|
||||||
columns before source inspection, reporting both as non-informative structural identifiers while
|
|
||||||
distinguishing declared constraints from inferred roles.
|
|
||||||
|
|
||||||
Physical membership, source
|
|
||||||
comments, column types/default/nullability/PK positions, and constraint-level ordered FK pairs are
|
|
||||||
projections of the external schema. They cannot be created, renamed, or structurally edited by
|
|
||||||
hand, but administrators can explicitly clear catalog tables, columns, or relationships without
|
|
||||||
touching the source database, binding, configuration, or secrets. Table deletion cascades through
|
|
||||||
columns and relationships; table-scoped relationship cleanup includes incoming and outgoing
|
|
||||||
relationships. Curated and generated descriptions are editable; generated descriptions start null
|
|
||||||
and Database Management can generate or consolidate them for selected tables, selected columns,
|
|
||||||
all targets, or only targets whose Generated Description is missing.
|
|
||||||
|
|
||||||
Relationship Management is now reachable directly from each configured Fleet database. One
|
|
||||||
Relationship Map shows read-only Physical Relationships together with Generated and Manual Logical
|
|
||||||
Relationships, with Active, Excluded, and All filters. Administrators can add a single-column
|
|
||||||
relationship, run deterministic name/PK/type inference, exclude or restore a logical relationship,
|
|
||||||
or delete it permanently. Exclusion retains a tombstone that a rebuild cannot reactivate; permanent
|
|
||||||
deletion allows a later rebuild to infer the same endpoints again. Inference uses no LLM, embedding,
|
|
||||||
or source values. It supports normalized table-qualified names, unique non-generic PK names,
|
|
||||||
composite-PK source columns, and the `*time_key -> dim_time.<single PK>` warehouse convention while
|
|
||||||
ignoring bare generic names. Explicit table/column metadata cleanup remains a destructive boundary: it removes
|
|
||||||
the attached logical relationships and exclusions and requires a full schema synchronization before
|
|
||||||
inference or runtime publication can continue.
|
|
||||||
|
|
||||||
The previous Database Management renderer remains a temporary comparison fallback for development
|
|
||||||
and staging only: `?db-ui=legacy` is honored in Vite development or when
|
|
||||||
`VITE_DB_MANAGEMENT_LEGACY=true`; it is not a production presentation. The standalone Fleet Ledger
|
|
||||||
prototype on port `5173` also remains temporary until owner acceptance of the integrated surface,
|
|
||||||
after which both migration aids can be removed.
|
|
||||||
|
|
||||||
Schema refresh is one durable asynchronous engine with database-table, selected-table-column,
|
|
||||||
relationship, and full-database actions. Database-level menus expose only the table, relationship,
|
|
||||||
and full scopes; selecting tables exposes column synchronization plus manual column and relationship cleanup for that subset. Database selections
|
|
||||||
also expose manual table and relationship cleanup. Cleanup selections are atomic and share the
|
|
||||||
one-active-operation-per-database exclusion with synchronization. Runs have leases and
|
|
||||||
restart recovery, atomic apply, destructive-diff confirmation with re-scan, cancellation before
|
|
||||||
apply, retained history, and a live SSE log with polling fallback. Null metadata renders blank
|
|
||||||
rather than as a placeholder.
|
|
||||||
|
|
||||||
Direct PostgreSQL and strict known-host-verified OpenSSH use `pg_catalog`. REST bindings use the
|
|
||||||
typed full-snapshot `POST /rpc/schema_snapshot` contract when available. Servers such as the
|
|
||||||
current PSD endpoint that exposes only `POST /rpc/run_query` use one catalog-owned read-only query
|
|
||||||
to return the exact same strict v1 snapshot in a single round trip. Both paths remain fail-closed:
|
|
||||||
an absent capability, query error, partial result, or invalid snapshot applies no catalog changes.
|
|
||||||
SSH is not yet enabled for NL→SQL session runtime.
|
|
||||||
|
|
||||||
The catalog runs in the internal `catalog-db` PostgreSQL service. Kysely migrations are an explicit
|
|
||||||
one-shot `catalog-migrate` operation; `scripts/run-stack.sh` runs it before local startup. Runtime
|
|
||||||
sessions consume an immutable Catalog JSON snapshot tied to the runtime-config lease. It contains
|
|
||||||
the tables, columns, effective descriptions, sensitivity flags, and active relationships used by
|
|
||||||
the harness; PostgreSQL is the exclusive runtime authority for database metadata. Authored
|
|
||||||
workspace YAML remains limited to workspace identity and optional Evidence configuration. The
|
|
||||||
accepted design is recorded in ADR 0016 and the contracts under `docs/contracts/`.
|
|
||||||
|
|
||||||
Semantic aliases, value descriptions, synonyms, and concepts remain deferred to their dedicated
|
|
||||||
slices.
|
|
||||||
|
|
||||||
AI Description Generation uses the catalog's human-owned Sensitive Data Flag. The flag defaults to
|
|
||||||
`false`, including for newly synchronized columns. An administrator may request a local sensitivity
|
|
||||||
analysis for one selected database, selected tables, or selected columns. One deterministic
|
|
||||||
TypeScript classifier combines metadata, bounded source-content rules, and optional CPU-only NER;
|
|
||||||
no generative model decides the result. Its `sensitive` or `non_sensitive` assessments remain an
|
|
||||||
unsaved draft until the human reviews and saves any chosen flag changes, including a downgrade to
|
|
||||||
non-sensitive. Coverage is reported separately; interrupted history may count unprocessed columns.
|
|
||||||
Each started analysis records a separate Sensitivity Analysis Run with aggregate counters and safe
|
|
||||||
ordered events. The progress drawer opens before the synchronous request completes, polls the run,
|
|
||||||
and displays sanitized source-scan and local-NER phase/batch activity while classification is in
|
|
||||||
progress. This operational history never stores per-column assessments, source values,
|
|
||||||
matched spans, prompts, or free-form diagnostics. Saving a sensitive decision persists a sanitized
|
|
||||||
Sensitivity Reason as column Catalog Metadata alongside the human-owned flag; clearing the flag
|
|
||||||
clears that reason. Reloading still discards an unsaved review draft.
|
|
||||||
For unprotected columns, up to five source rows and five representative non-null values may be sent
|
|
||||||
transiently to the configured model provider. Protected columns are omitted from source reads and
|
|
||||||
replaced in the prompt by deterministic plausible values derived only from their metadata. Existing
|
|
||||||
descriptions are not regenerated when a flag changes.
|
|
||||||
|
|
||||||
The accepted AI-description design is recorded in
|
|
||||||
`docs/plans/2026-08-28-ai-catalog-description-generation.md`, with the formal specification in the
|
|
||||||
adjacent `-spec.md` document and Gitea issue #4. Gitea issues #5–#11 deliver the implementation.
|
|
||||||
The runtime deliberately keeps ThothAI's simple operating model: one installation-wide sequential
|
|
||||||
run owned by the backend, one short-lived Python/LiteLLM completion helper per request, and
|
|
||||||
persistence limited to the run, its safe ordered text events, and each Generated Description as
|
|
||||||
soon as it succeeds. The helper performs at most one provider retry and never falls back to another
|
|
||||||
model. Stop terminates the current helper and retains prior results; three consecutive exhausted
|
|
||||||
technical batches fail the run. Startup marks stale queued/running work interrupted, and Unlock is
|
|
||||||
available only when no local start, worker, or helper is live. Runs remain inspectable through a
|
|
||||||
live SSE log with ordered polling fallback; there is no automatic resume or user-facing generation
|
|
||||||
CLI. ADRs 0009–0010 record the runtime and source-sampling decisions.
|
|
||||||
|
|
||||||
The Installation Model Catalog accepts the protected `DEEPSEEK_API_KEY` and `ZAI_API_KEY`
|
|
||||||
references for metadata-generation providers.
|
|
||||||
It also accepts a model with no secret reference only when its OpenAI-compatible endpoint is
|
|
||||||
explicit; this covers the VPN-only AritmoLab Qwen 3.6 server without creating a fake operator
|
|
||||||
credential. The Python client supplies only its fixed non-secret compatibility placeholder.
|
|
||||||
The AritmoLab entry also sets `disableThinking: true`, mapped to the endpoint's chat-template flag,
|
|
||||||
because its default reasoning prose would violate the worker's exact JSON response contract.
|
|
||||||
|
|
||||||
Logical relationship integration with core schema-linking is complete: session creation and resume
|
|
||||||
materialize the active physical/generated/manual map, retrieval-pack generation and Pi receive the
|
|
||||||
same runtime config, and snapshot validation fails closed on a declared missing, invalid, or orphaned
|
|
||||||
endpoint. Broader publication of other Catalog metadata to schema-linking remains a separate future
|
|
||||||
slice.
|
|
||||||
|
|
||||||
**Deferred follow-up — Sensitive Data Policy in schema-linking.** The policy is first delivered
|
|
||||||
and tested in catalog description generation. Its enforcement for core schema-linking remains
|
|
||||||
out of scope until the current tickets are closed and the owner has completed the acceptance test.
|
|
||||||
At that gate, resume the design: `tht` must receive a read-only projection of the current Sensitive
|
|
||||||
Data Flags and exclude values from columns marked sensitive from every LSH result before it is
|
|
||||||
given to Pi. Do not start this integration before the owner gives final approval after that test.
|
|
||||||
|
|
||||||
## Active deployment work and manual gates
|
|
||||||
|
|
||||||
### PSD server deployment program
|
|
||||||
|
|
||||||
The approved design and executable entry point are:
|
|
||||||
|
|
||||||
- `docs/plans/2026-08-20-psd-server-deployment-program-design.md`
|
|
||||||
- `docs/plans/2026-08-20-psd-server-deployment-program.md`
|
|
||||||
- `docs/plans/2026-08-20-psd-server-survey.md`
|
|
||||||
- `docs/plans/2026-08-20-psd-server-project-a-standalone.md`
|
|
||||||
- `docs/plans/2026-08-20-psd-server-project-b-authentik.md`
|
|
||||||
|
|
||||||
Last recorded state:
|
|
||||||
|
|
||||||
- survey: `SURVEY_NO_GO`;
|
|
||||||
- Project A: `BLOCKED_BY_SURVEY_AND_MUTATION_GATE`;
|
|
||||||
- Project B: `BLOCKED_BY_PROJECT_A_AND_PRE_B_GATE`.
|
|
||||||
|
|
||||||
The deployment is a clean replacement: legacy sessions, indexes, and application configuration
|
|
||||||
are not migration inputs. The existing stack remains intact until its documented mutation and
|
|
||||||
rollback gates are explicitly approved. Shared Omics/LocalLLM networks, ETL Evidence, DWH,
|
|
||||||
`dwh-auth`, Supabase, Authentik, Superset, and Aritmolab are outside cleanup scope.
|
|
||||||
|
|
||||||
Human acceptance guides and sanitized report templates live under `docs/testing/` and
|
|
||||||
`docs/testing/evidence/`. The remediation checklist is
|
|
||||||
`docs/operations/psd-server-survey-remediation-checklist.md`.
|
|
||||||
|
|
||||||
### Authentication
|
|
||||||
|
|
||||||
The local/OIDC authentication remediation passed its automated review on 2026-08-18. Release and
|
|
||||||
PSD mutation gates remain governed by:
|
|
||||||
|
|
||||||
- `docs/architecture/authentication.md`;
|
|
||||||
- `docs/plans/2026-08-18-thothii-authentication-acceptance-and-psd-deployment.md`;
|
|
||||||
- `docs/operations/psd-dwh-auth-rollout.md`;
|
|
||||||
- `docs/testing/authentication-manual-acceptance.md`.
|
|
||||||
|
|
||||||
Do not infer authorization for server, Nginx, Authentik, database, credential, or cutover changes
|
|
||||||
from an automated PASS.
|
|
||||||
|
|
||||||
## Verification status
|
|
||||||
|
|
||||||
- The P1.1 workspace-directory registry and P2–P6 preprocessing workstreams are implemented and
|
|
||||||
have automated coverage.
|
|
||||||
- Evidence restructuring has a real PSD acceptance PASS as recorded above.
|
|
||||||
- AI Description Generation has automated coverage across installation setup, model selection,
|
|
||||||
generation/consolidation scopes, bounded sampling, cancellation/recovery, history, SSE/polling,
|
|
||||||
and the LiteLLM helper boundary.
|
|
||||||
- L2 tests requiring real providers or remote databases remain opt-in.
|
|
||||||
- Server deployment, release, and owner-operated acceptance steps remain pending wherever the
|
|
||||||
referenced runbooks require explicit approval.
|
|
||||||
|
|
||||||
Run the layer-specific checks documented in `AGENTS.md`. For release-sensitive changes, also run
|
|
||||||
the repository contract scripts in `scripts/` and build the MkDocs site.
|
|
||||||
|
|
||||||
## Operational invariants
|
|
||||||
|
|
||||||
- `tht`'s `-c`/`--config` option follows the subcommand; it is not a global option.
|
|
||||||
- `--json` commands write pristine JSON to stdout.
|
|
||||||
- Persisted phase documents and the decision ledger are the source of session truth; chat is not.
|
|
||||||
- UI chrome is English; workspace document content retains the workspace language.
|
|
||||||
- The backend refuses resume for finalized or archived sessions.
|
|
||||||
- A resume must send `/riprendi-sessione <id>`; a new session must send `/nuova-domanda`.
|
|
||||||
- DWH access is read-only.
|
|
||||||
|
|||||||
@@ -21,69 +21,35 @@ authentication is established by the trusted server proxy. See the
|
|||||||
[upstream integration](docs/install/authentication-upstream.md), and
|
[upstream integration](docs/install/authentication-upstream.md), and
|
||||||
[manual acceptance matrix](docs/testing/authentication-manual-acceptance.md).
|
[manual acceptance matrix](docs/testing/authentication-manual-acceptance.md).
|
||||||
|
|
||||||
## Docker Compose: local startup
|
For the clone-based manual standalone installation test on macOS, Windows, and Linux, use the
|
||||||
|
[Italian procedure](docs/install/standalone-manual-it.md) or the
|
||||||
|
[English procedure](docs/install/standalone-manual-en.md).
|
||||||
|
|
||||||
Requirements: Docker Engine with Compose v2. The mandatory stack is `frontend`, `core`,
|
The [public manual](https://git.tylconsulting.it/thothii-docs/) covers the product,
|
||||||
`catalog-db`, `qdrant`, `embedding`, and the one-shot `embedding-model-init`. DWH and LLM remain external,
|
installation, use and administration. Developer architecture, contracts, ADRs, tests,
|
||||||
configurable endpoints—even when they are co-located with ThothII.
|
plans and release records remain in this repository but are excluded from MkDocs
|
||||||
|
pages and search. This is an editorial boundary, not an access restriction on the
|
||||||
|
public repository. See the [documentation cleanup review](docs/maintenance/2026-09-15-documentation-cleanup.md)
|
||||||
|
for the executed consolidation and the inventory of historical sources retained in Git.
|
||||||
|
|
||||||
From a fresh clone, run these commands from the repository root:
|
## Docker Compose and installation
|
||||||
|
|
||||||
```sh
|
For a fresh installation, follow the guided terminal procedure in
|
||||||
cp deploy/env/local.env.example deploy/env/local.env
|
[Italian](docs/install/standalone-manual-it.md) or
|
||||||
# Copy docs/install/examples/thothii-installation.local.yaml to a protected operator path,
|
[English](docs/install/standalone-manual-en.md). The single
|
||||||
# replace its placeholders, chmod it 600, and set that exact THT_INSTALLATION_CONFIG_SOURCE.
|
`tht setup --complete` command validates protected files, builds the images, runs
|
||||||
# Edit deploy/env/local.env, including PI_AUTH_FILE, THT_SECRETS_FILE, and external endpoints.
|
Catalog migration, starts the stack and imports the configured workspace repository.
|
||||||
./scripts/run-stack.sh
|
There is no graphical installer or native launcher.
|
||||||
```
|
|
||||||
|
|
||||||
The launcher builds the core, starts `catalog-db`, runs the explicit one-shot Kysely migrations,
|
The mandatory stack includes frontend, core, PostgreSQL catalog, Qdrant, Ollama
|
||||||
then runs the base+local stack in the foreground. Migrations never run implicitly in backend
|
and the embedding initializer. DWH and LLM endpoints remain external dependencies.
|
||||||
startup. The core image contains its Pi runtime; no host `pi` executable is used. For a server
|
Pi is included in the core image. Credentials and certificates belong in protected
|
||||||
installation, build the image, start the catalog, and run the same migration service before the
|
installation-local files, never in the workspace repository.
|
||||||
application rollout:
|
|
||||||
|
|
||||||
```sh
|
For developer topology, overlays and lifecycle details, see the internal
|
||||||
cp deploy/env/server.env.example deploy/env/server.env
|
[Compose reference](docs/operations/compose-reference.md). Ordinary stop/down keeps
|
||||||
# Prepare a mode-600 thothii-installation.yaml from the server example and set its exact
|
persistent data; removing volumes is destructive and is not an upgrade step.
|
||||||
# path as THT_INSTALLATION_CONFIG_SOURCE. Edit all remaining storage/secret/endpoint paths.
|
Process health is distinct from external dependency checks performed by doctor.
|
||||||
sudo scripts/prepare-server-pi-state.sh /srv/thothii/pi-state 10001 10001
|
|
||||||
docker compose --env-file deploy/env/server.env \
|
|
||||||
-f compose.yaml -f deploy/compose.server.yaml \
|
|
||||||
-f deploy/compose.session-server.yaml.example build core
|
|
||||||
docker compose --env-file deploy/env/server.env \
|
|
||||||
-f compose.yaml -f deploy/compose.server.yaml \
|
|
||||||
-f deploy/compose.session-server.yaml.example up -d catalog-db
|
|
||||||
docker compose --env-file deploy/env/server.env \
|
|
||||||
-f compose.yaml -f deploy/compose.server.yaml \
|
|
||||||
-f deploy/compose.session-server.yaml.example run --rm catalog-migrate
|
|
||||||
docker compose --env-file deploy/env/server.env \
|
|
||||||
-f compose.yaml -f deploy/compose.server.yaml \
|
|
||||||
-f deploy/compose.session-server.yaml.example up --build -d
|
|
||||||
```
|
|
||||||
|
|
||||||
The initializer is required for an empty or restored server Pi-state bind. It atomically creates
|
|
||||||
the three regular targets hidden below the writable parent bind; protected Pi auth and tracked
|
|
||||||
model/settings sources remain separate read-only mounts. See the server manual before substituting
|
|
||||||
a root other than `/srv/thothii/pi-state`.
|
|
||||||
|
|
||||||
Workspace descriptors come from the Git remote configured by `THT_WORKSPACE_GIT_REMOTE`; their
|
|
||||||
runtime endpoint and secret bindings remain installation-local. Open
|
|
||||||
<http://127.0.0.1:8080> (set `THOTH_HTTP_PORT` in `deploy/env/local.env` to choose another
|
|
||||||
loopback port).
|
|
||||||
|
|
||||||
Credentials and certificates are local protected files. Do not put them in environment examples,
|
|
||||||
workspace YAML, URLs, or Compose interpolation values.
|
|
||||||
|
|
||||||
Application state is split across the named `settings`, `pi-state`, `workspace-registry`,
|
|
||||||
`sessions`, `qdrant-data`, and `embedding-models` volumes. `docker compose down` keeps them.
|
|
||||||
`qdrant-data` is a derived but persistent index store; `embedding-models` is an Ollama model
|
|
||||||
cache for `qwen3-embedding:0.6b` with fixed `1024`-dimension embeddings. Only an explicit destructive command such as `docker compose
|
|
||||||
down --volumes` removes them.
|
|
||||||
|
|
||||||
The frontend depends on the core health check and proxies `/health` and `/api/*` to it. The
|
|
||||||
application health endpoint intentionally checks process readiness only; external dependency
|
|
||||||
diagnostics are exposed by `tht doctor` and do not prevent the UI from starting.
|
|
||||||
|
|
||||||
## Git-backed workspace repository
|
## Git-backed workspace repository
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,13 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "thothii-backend",
|
"name": "thothii-backend",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@aws-sdk/client-s3": "3.1141.0",
|
||||||
"@fastify/cookie": "11.1.2",
|
"@fastify/cookie": "11.1.2",
|
||||||
"@fastify/cors": "^11.2.0",
|
"@fastify/cors": "^11.2.0",
|
||||||
"@fastify/rate-limit": "11.2.0",
|
"@fastify/rate-limit": "11.2.0",
|
||||||
"@types/pg": "^8.20.3",
|
"@types/pg": "^8.20.3",
|
||||||
"fastify": "^5.0.0",
|
"fastify": "^5.0.0",
|
||||||
|
"ipaddr.js": "2.4.0",
|
||||||
"kysely": "^0.29.5",
|
"kysely": "^0.29.5",
|
||||||
"libphonenumber-js": "1.13.12",
|
"libphonenumber-js": "1.13.12",
|
||||||
"openid-client": "6.8.5",
|
"openid-client": "6.8.5",
|
||||||
@@ -23,11 +25,320 @@
|
|||||||
"@testcontainers/postgresql": "^12.1.0",
|
"@testcontainers/postgresql": "^12.1.0",
|
||||||
"@types/node": "24.13.3",
|
"@types/node": "24.13.3",
|
||||||
"@types/validator": "13.15.10",
|
"@types/validator": "13.15.10",
|
||||||
|
"bun": "1.4.2",
|
||||||
"tsx": "^4.19.0",
|
"tsx": "^4.19.0",
|
||||||
"typescript": "^5.6.0",
|
"typescript": "^5.6.0",
|
||||||
"vitest": "^2.1.0"
|
"vitest": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@aws-sdk/checksums": {
|
||||||
|
"version": "3.1001.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/checksums/-/checksums-3.1001.1.tgz",
|
||||||
|
"integrity": "sha512-x12Q17KYlJAd3nKf8LV5LV0vt8sh8/6YfQLGPtrGnQf/tW4jqxPGq5GPpuVitpQYM3eUR4XB7CbxZf751NMbLw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/client-s3": {
|
||||||
|
"version": "3.1141.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/client-s3/-/client-s3-3.1141.0.tgz",
|
||||||
|
"integrity": "sha512-uOVH37xGLenAdJkCPCin/JJG2PgWrFcSsDnQ9+C9Zq8N9Oalo5ol4xmn5fG28iWAlA/b/9boQZgHbMh+UsIhcg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/checksums": "^3.1001.1",
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/credential-provider-node": "^3.972.84",
|
||||||
|
"@aws-sdk/middleware-sdk-s3": "^3.972.77",
|
||||||
|
"@aws-sdk/signature-v4-multi-region": "^3.996.47",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/fetch-http-handler": "^5.8.0",
|
||||||
|
"@smithy/node-http-handler": "^4.12.1",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/core": {
|
||||||
|
"version": "3.978.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.978.1.tgz",
|
||||||
|
"integrity": "sha512-LbY9aGsEiznDWmUc30Nwv3aIX/+dbwTx8KfS0yOC3NPYMO+O91e6jkT1azf34FwjOndq8/Q+RcVVZz5xnerwdg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@aws-sdk/xml-builder": "^3.972.41",
|
||||||
|
"@aws/lambda-invoke-store": "^0.3.0",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/signature-v4": "^5.7.3",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"bowser": "^2.11.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-env": {
|
||||||
|
"version": "3.972.72",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.72.tgz",
|
||||||
|
"integrity": "sha512-xTKO/FWJPozTIXbozVnVGoNBhaGba8TBcx+KyUjRVeOlXE+dUc7GTR1cLvu0uTdIdmemzaFbqqCshXeZA1fZew==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-http": {
|
||||||
|
"version": "3.972.74",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.74.tgz",
|
||||||
|
"integrity": "sha512-u91E/hT8f4d1xy0Jl7VG4nVKJ3lxbrZkoBTeSVoJdWBiSEUMwMS/9+e0H/aJVQV//Lt5wuzP+E69v4aRSsNTmw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/fetch-http-handler": "^5.8.0",
|
||||||
|
"@smithy/node-http-handler": "^4.12.1",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-ini": {
|
||||||
|
"version": "3.973.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.17.tgz",
|
||||||
|
"integrity": "sha512-ged4KXdBkvIC81bLvNHHuQKdKak/VXhQTR1NWYTTqW0474nlmsxy9O/vlgTIohDDWH3xpBdtVMZRyjb+DnocDA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/credential-provider-env": "^3.972.72",
|
||||||
|
"@aws-sdk/credential-provider-http": "^3.972.74",
|
||||||
|
"@aws-sdk/credential-provider-login": "^3.972.79",
|
||||||
|
"@aws-sdk/credential-provider-process": "^3.972.72",
|
||||||
|
"@aws-sdk/credential-provider-sso": "^3.973.16",
|
||||||
|
"@aws-sdk/credential-provider-web-identity": "^3.972.78",
|
||||||
|
"@aws-sdk/nested-clients": "^3.997.46",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/credential-provider-imds": "^4.5.2",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-login": {
|
||||||
|
"version": "3.972.79",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.79.tgz",
|
||||||
|
"integrity": "sha512-L+Z85anONJd8MaiuraO4wRxATCdEejBZ3K3eymzWI5JPXa9sOS9CkIm72PBKqXKX+Z9p9NGMX5AIMXm0LEflgw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/nested-clients": "^3.997.46",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-node": {
|
||||||
|
"version": "3.972.84",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.84.tgz",
|
||||||
|
"integrity": "sha512-oHt854odINVwzwsh+c5x69j0ajm4DbqqqVJ+O1ECsCIZeMDAbzFpXItaqP7UZstJj/ATdTk/KFSH0LaNAgV+kA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/credential-provider-env": "^3.972.72",
|
||||||
|
"@aws-sdk/credential-provider-http": "^3.972.74",
|
||||||
|
"@aws-sdk/credential-provider-ini": "^3.973.17",
|
||||||
|
"@aws-sdk/credential-provider-process": "^3.972.72",
|
||||||
|
"@aws-sdk/credential-provider-sso": "^3.973.16",
|
||||||
|
"@aws-sdk/credential-provider-web-identity": "^3.972.78",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/credential-provider-imds": "^4.5.2",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-process": {
|
||||||
|
"version": "3.972.72",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.72.tgz",
|
||||||
|
"integrity": "sha512-rLIp2xbMjX/k9/od7APpqq1ZgXXnV0pOL1Th3ZsL8Wu0TRtBsDTVS8iPqcfRFcHakFxPvR04OSTv2ka2qOb/2A==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-sso": {
|
||||||
|
"version": "3.973.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.16.tgz",
|
||||||
|
"integrity": "sha512-IGihaJfFZYacJJr/odqILCoK7W/mvrZ7cuK7ECn3sAu4vLC6u0V8bS7mCGbdugJ8Aum2tnvqmx0F2MRFp2rn9g==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/nested-clients": "^3.997.46",
|
||||||
|
"@aws-sdk/token-providers": "3.1138.0",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/credential-provider-web-identity": {
|
||||||
|
"version": "3.972.78",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.78.tgz",
|
||||||
|
"integrity": "sha512-/y9WvNtlcPBGLR0qc1a+9J/xtYZfVczvLUOuXaVWylzttH7ewsxwHtjmiJSolNrVSDorIxHGHMU61CbonRkmwA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/nested-clients": "^3.997.46",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/middleware-sdk-s3": {
|
||||||
|
"version": "3.972.77",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/middleware-sdk-s3/-/middleware-sdk-s3-3.972.77.tgz",
|
||||||
|
"integrity": "sha512-E7W2UOeUoc+lg3uIfR/dM7ZwusHwhBQrKMnlkRv4EXRR+C0YtV1pg25xC7GdZIhXH+NAMgZPCbE7o5to2cjFiw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/signature-v4-multi-region": "^3.996.47",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/nested-clients": {
|
||||||
|
"version": "3.997.46",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.46.tgz",
|
||||||
|
"integrity": "sha512-oRxtBcka/JGHGs9l9p9IVajGoTP8vTPmoAzdHGy4Qcy9P5vPnDf6nhIeM/COQNY9k/OahImTRaLkHftoXvfcmQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/signature-v4-multi-region": "^3.996.47",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/fetch-http-handler": "^5.8.0",
|
||||||
|
"@smithy/node-http-handler": "^4.12.1",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/signature-v4-multi-region": {
|
||||||
|
"version": "3.996.47",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.47.tgz",
|
||||||
|
"integrity": "sha512-Zk08macMvQTHzQJCLJVkOlviVoqwYMrpXv4lmLN7b7sAbiMoOK7Go0NYdR5UeF+MW8LIbRmwrNy9u/5VvX1U5g==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/signature-v4": "^5.7.3",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/token-providers": {
|
||||||
|
"version": "3.1138.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1138.0.tgz",
|
||||||
|
"integrity": "sha512-GpyAr0DD63YOEmYFM6Df+gJuIgC92MMTiBK4FTKfxii5MJ9ge20epR7LyroulscYlG89J+ZB2ivFDPjvfQhzdw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@aws-sdk/core": "^3.978.1",
|
||||||
|
"@aws-sdk/nested-clients": "^3.997.46",
|
||||||
|
"@aws-sdk/types": "^3.974.6",
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/types": {
|
||||||
|
"version": "3.974.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.974.6.tgz",
|
||||||
|
"integrity": "sha512-v/clNZzZnDxGyvpHMOGpJKVXFAExJzUNAAjaWGdcx8QAcXLGwTaOkw33p5SHAi0YAioK32xB3hWwOekRVfmfKg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws-sdk/xml-builder": {
|
||||||
|
"version": "3.972.41",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.41.tgz",
|
||||||
|
"integrity": "sha512-ctjVSyCMegrWfXlx6VqzSBFI6UqmQ5ZlnfMhdLIiWmhoH8UAQxSCP5N3OpG7X3k4LnS7ou74C4mt20+bfTW2aQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@aws/lambda-invoke-store": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.3.0.tgz",
|
||||||
|
"integrity": "sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@balena/dockerignore": {
|
"node_modules/@balena/dockerignore": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz",
|
||||||
@@ -802,6 +1113,174 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@oven/bun-darwin-aarch64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-MXdZkP1featqxZ+/VTXWG1BVjM4OGBehVY2Q88EeUj/7L0UMeCGItmyPYTN+wxvlGJ6F66JEtzsw+GvQWewnag==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-darwin-x64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-gZTxZuLjkUhAWjTETu3tw0WhsEdNkJ64daj60ybhPf835a2yollV3yTkK9JozvzKPx4TRFzLSl8C+U525pxVbw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-freebsd-aarch64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-freebsd-aarch64/-/bun-freebsd-aarch64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-SMNItMw1Z8QeeQVKnw8jA7xQNkeXdP+OPgin4Wi/QTx/B8RHHLnuZfqmFy7NtVeT2NF0kKYppW4WWd2CCYZjhQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-freebsd-x64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-freebsd-x64/-/bun-freebsd-x64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-THbPKXhO54N0DpFRKZNDZpQ7dpbX0bWASuARckAUS9wRtFIHsiY+uULXJvxJGo2YD1YewvXQ4G8Fj7XT5oBCiw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-aarch64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-3BBP9ovJ2RGHFH6Ae1CAtxNtG1+YY6GD6rmYbsUosoAk9+OEl6zeDQ/k4fBkc6dYOJCtWnx8hUxzNzQATSmvYQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-aarch64-android": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-android/-/bun-linux-aarch64-android-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-3mZKO2rhsNgbAUtAHC1UKUlF2zTxFraDZT/Elv8wzyH0fJL9h+Iv3TgB9lO63w89PRn3eFe+NRA1bhVgikKNPQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-aarch64-musl": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-+Sm6y+lSiSFBOtXmnekp5Q6n1tUKlyv71FCPWBc61Cgb14T5eBs8SN/nh4MUCOKzONkI3O+as3MGUgikS4aCBQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-x64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-9/E/UXOTpSo3YsV5g+FhtTd/qTpiWoKuxS12cqtuYA1ssu9fRAoPQnipFgGyck3tWO63iUdxBiygq+kELFawng==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-x64-android": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-android/-/bun-linux-x64-android-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-6HC5tzcC79113n2IHCTJMWv+HsQImv4ZFEK2XpYLxY6HbT8tM4cUM2Zv1bHZBQsS3jv/zYBamDJ1UX7If0d5tw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-linux-x64-musl": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-vVTKUg1bnPhRP/Hp73jIVoFh2vPFNYEqYX0ERKfZBOQEEHitNAeukZzzuUDZS0SoDCIpuWUGSpd/CDMbjdR+Uw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-windows-aarch64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-windows-aarch64/-/bun-windows-aarch64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-8EJ1ST7339WJE3poPW5nBgVW/lWf9HBz4W27ZUNhburKmcBLOByPyE6DP9fHD8FQGm5c+ilUN2hX1mrW0jxq9Q==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@oven/bun-windows-x64": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-+bN6OuVld/9diT/RLSXSW7JE6CvNE3gL9XsAEjULi1nUsXd6DNO6GuA9jNdNb3r8PdJFnYHr5aypNV1Oj3Rd9g==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@pinojs/redact": {
|
"node_modules/@pinojs/redact": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
|
||||||
@@ -1235,6 +1714,87 @@
|
|||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@smithy/core": {
|
||||||
|
"version": "3.35.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.35.0.tgz",
|
||||||
|
"integrity": "sha512-zRMhfkByhT2snNdr1si24vJitU6Cr9ix2MikUfWmkAgp4jrNP0GcKSP5YvwQ+TlI8AZXER5QOGJn3JsVtSD9/A==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@smithy/credential-provider-imds": {
|
||||||
|
"version": "4.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz",
|
||||||
|
"integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/core": "^3.33.2",
|
||||||
|
"@smithy/types": "^4.17.2",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@smithy/fetch-http-handler": {
|
||||||
|
"version": "5.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.0.tgz",
|
||||||
|
"integrity": "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/core": "^3.33.3",
|
||||||
|
"@smithy/types": "^4.18.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@smithy/node-http-handler": {
|
||||||
|
"version": "4.12.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.12.1.tgz",
|
||||||
|
"integrity": "sha512-ThMkboGeONWXAelq9FvGsuJC4rOi+qyC4/zhUF58xYpxUg5sQKx2VXZYJmtNjr4dSuBJ1HeJXETQILCz3wOHvw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/core": "^3.33.3",
|
||||||
|
"@smithy/types": "^4.18.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@smithy/signature-v4": {
|
||||||
|
"version": "5.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.4.tgz",
|
||||||
|
"integrity": "sha512-tHy0K0VtqNd5Y7Y41h0a0Lhh0L1GzC08dTWg0F7vRJWFtTENg7IZikf3wQkanYIRdb7ngoIPMTmqgUi401fEeQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@smithy/core": "^3.35.0",
|
||||||
|
"@smithy/types": "^4.19.0",
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@smithy/types": {
|
||||||
|
"version": "4.19.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.19.0.tgz",
|
||||||
|
"integrity": "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@testcontainers/postgresql": {
|
"node_modules/@testcontainers/postgresql": {
|
||||||
"version": "12.1.0",
|
"version": "12.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@testcontainers/postgresql/-/postgresql-12.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@testcontainers/postgresql/-/postgresql-12.1.0.tgz",
|
||||||
@@ -1821,6 +2381,12 @@
|
|||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bowser": {
|
||||||
|
"version": "2.14.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz",
|
||||||
|
"integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||||
@@ -1876,6 +2442,43 @@
|
|||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bun": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/bun/-/bun-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-TrSXo6HJfIEaczpb3kjX82I2pL47vK1QUNmHRCUdz9IzaOwa9lzOXSWwu2l18YHE3sNfGRapVLd4nNm+22vVVA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64",
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"os": [
|
||||||
|
"darwin",
|
||||||
|
"linux",
|
||||||
|
"android",
|
||||||
|
"freebsd",
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"bun": "bin/bun.exe",
|
||||||
|
"bunx": "bin/bunx.exe"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@oven/bun-darwin-aarch64": "1.4.2",
|
||||||
|
"@oven/bun-darwin-x64": "1.4.2",
|
||||||
|
"@oven/bun-freebsd-aarch64": "1.4.2",
|
||||||
|
"@oven/bun-freebsd-x64": "1.4.2",
|
||||||
|
"@oven/bun-linux-aarch64": "1.4.2",
|
||||||
|
"@oven/bun-linux-aarch64-android": "1.4.2",
|
||||||
|
"@oven/bun-linux-aarch64-musl": "1.4.2",
|
||||||
|
"@oven/bun-linux-x64": "1.4.2",
|
||||||
|
"@oven/bun-linux-x64-android": "1.4.2",
|
||||||
|
"@oven/bun-linux-x64-musl": "1.4.2",
|
||||||
|
"@oven/bun-windows-aarch64": "1.4.2",
|
||||||
|
"@oven/bun-windows-x64": "1.4.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/byline": {
|
"node_modules/byline": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz",
|
||||||
@@ -4114,6 +4717,12 @@
|
|||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tslib": {
|
||||||
|
"version": "2.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||||
|
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||||
|
"license": "0BSD"
|
||||||
|
},
|
||||||
"node_modules/tsx": {
|
"node_modules/tsx": {
|
||||||
"version": "4.22.4",
|
"version": "4.22.4",
|
||||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.22.4.tgz",
|
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.22.4.tgz",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"build:workspace-tools": "node scripts/build-workspace-tools.mjs",
|
||||||
"dev": "tsx watch src/server.ts",
|
"dev": "tsx watch src/server.ts",
|
||||||
"prebuild": "node scripts/clean-dist.mjs",
|
"prebuild": "node scripts/clean-dist.mjs",
|
||||||
"build": "tsc -p tsconfig.json",
|
"build": "tsc -p tsconfig.json",
|
||||||
@@ -14,11 +15,13 @@
|
|||||||
"test:schema-v3-verifier": "npm run test:schema-v4-verifier"
|
"test:schema-v3-verifier": "npm run test:schema-v4-verifier"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@aws-sdk/client-s3": "3.1141.0",
|
||||||
"@fastify/cookie": "11.1.2",
|
"@fastify/cookie": "11.1.2",
|
||||||
"@fastify/cors": "^11.2.0",
|
"@fastify/cors": "^11.2.0",
|
||||||
"@fastify/rate-limit": "11.2.0",
|
"@fastify/rate-limit": "11.2.0",
|
||||||
"@types/pg": "^8.20.3",
|
"@types/pg": "^8.20.3",
|
||||||
"fastify": "^5.0.0",
|
"fastify": "^5.0.0",
|
||||||
|
"ipaddr.js": "2.4.0",
|
||||||
"kysely": "^0.29.5",
|
"kysely": "^0.29.5",
|
||||||
"libphonenumber-js": "1.13.12",
|
"libphonenumber-js": "1.13.12",
|
||||||
"openid-client": "6.8.5",
|
"openid-client": "6.8.5",
|
||||||
@@ -31,6 +34,7 @@
|
|||||||
"@testcontainers/postgresql": "^12.1.0",
|
"@testcontainers/postgresql": "^12.1.0",
|
||||||
"@types/node": "24.13.3",
|
"@types/node": "24.13.3",
|
||||||
"@types/validator": "13.15.10",
|
"@types/validator": "13.15.10",
|
||||||
|
"bun": "1.4.2",
|
||||||
"tsx": "^4.19.0",
|
"tsx": "^4.19.0",
|
||||||
"typescript": "^5.6.0",
|
"typescript": "^5.6.0",
|
||||||
"vitest": "^2.1.0"
|
"vitest": "^2.1.0"
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
// Maintainer-only build. The resulting two-binary bundle needs no extra host runtime.
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
|
import { dirname, join, resolve } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const repository = process.env.THT_BUILD_SOURCE_ROOT ? resolve(process.env.THT_BUILD_SOURCE_ROOT) : resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
||||||
|
const backend = join(repository, "backend");
|
||||||
|
const native = `${process.platform === "win32" ? "windows" : process.platform}-${process.arch === "x64" ? "amd64" : process.arch}`;
|
||||||
|
const targets = {
|
||||||
|
"windows-amd64": ["windows", "amd64", "bun-windows-x64"],
|
||||||
|
"darwin-amd64": ["darwin", "amd64", "bun-darwin-x64"],
|
||||||
|
"darwin-arm64": ["darwin", "arm64", "bun-darwin-arm64"],
|
||||||
|
"linux-amd64": ["linux", "amd64", "bun-linux-x64"],
|
||||||
|
"linux-arm64": ["linux", "arm64", "bun-linux-arm64"],
|
||||||
|
};
|
||||||
|
const requested = process.argv.slice(2);
|
||||||
|
const selected = requested.length === 1 && requested[0] === "--all" ? Object.keys(targets) : requested.length ? requested : [native];
|
||||||
|
if (selected.some((target) => !targets[target])) {
|
||||||
|
console.error(`Usage: npm run build:workspace-tools -- [${Object.keys(targets).join("|")}|--all]`);
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
function run(command, args, cwd = backend, env = process.env) {
|
||||||
|
const result = spawnSync(command, args, { cwd, env, stdio: "inherit" });
|
||||||
|
if (result.error || result.status !== 0) throw new Error(`Build failed: ${command}`);
|
||||||
|
}
|
||||||
|
const revision = spawnSync("git", ["rev-parse", "HEAD"], { cwd: repository, encoding: "utf8" });
|
||||||
|
if (revision.status !== 0) throw new Error("Cannot read build revision");
|
||||||
|
const commit = revision.stdout.trim();
|
||||||
|
const buildTime = process.env.THT_BUILD_TIME ?? new Date().toISOString();
|
||||||
|
const releaseVersion = process.env.THT_BUILD_VERSION ?? "0.0.0-dev";
|
||||||
|
if (!/^[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?$/.test(releaseVersion) || !Number.isFinite(Date.parse(buildTime))) throw new Error("Invalid build identity");
|
||||||
|
const module = "github.com/aritmolab/thothii/tools/tht/internal/version";
|
||||||
|
const bunPackage = JSON.parse(readFileSync(join(backend, "node_modules", "bun", "package.json"), "utf8"));
|
||||||
|
const bun = join(backend, "node_modules", "bun", bunPackage.bin.bun);
|
||||||
|
for (const target of selected) {
|
||||||
|
const [os, arch, bunTarget] = targets[target];
|
||||||
|
const output = join(repository, "dist", "workspace-tools", target);
|
||||||
|
mkdirSync(output, { recursive: true });
|
||||||
|
const extension = os === "windows" ? ".exe" : "";
|
||||||
|
const names = [`tht${extension}`, `tht-workspace-documents${extension}`];
|
||||||
|
run(bun, ["build", "src/workspace-documents-cli.ts", "--compile", `--target=${bunTarget}`, "--outfile", join(output, names[1])]);
|
||||||
|
run("go", ["build", "-trimpath", "-ldflags", `-s -w -X ${module}.semanticVersion=${releaseVersion} -X ${module}.commit=${commit} -X ${module}.buildTime=${buildTime}`, "-o", join(output, names[0]), "./cmd/tht"], join(repository, "tools", "tht"), { ...process.env, CGO_ENABLED: "0", GOOS: os, GOARCH: arch });
|
||||||
|
const hashes = names.map((name) => `${createHash("sha256").update(readFileSync(join(output, name))).digest("hex")} ${name}\n`).join("");
|
||||||
|
writeFileSync(join(output, "SHA256SUMS"), hashes);
|
||||||
|
writeFileSync(join(output, "build.json"), JSON.stringify({ version: releaseVersion, commit, buildTime, target, bun: JSON.parse(readFileSync(join(backend, "package.json"), "utf8")).devDependencies.bun }, null, 2) + "\n");
|
||||||
|
console.log(output);
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Explicit advanced producer. The resulting bundle uses the ordinary document-first apply path.
|
||||||
|
import { mkdirSync, mkdtempSync, realpathSync, existsSync, readFileSync, rmSync, copyFileSync, chmodSync } from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join, resolve } from 'node:path';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
|
import { randomBytes } from 'node:crypto';
|
||||||
|
import { parse } from 'yaml';
|
||||||
|
import { prepareBundle } from './release-bundle.mjs';
|
||||||
|
import { commandRunner } from './publish-installation.mjs';
|
||||||
|
import { dockerHub } from './release-registry.mjs';
|
||||||
|
|
||||||
|
const repositoryRoot = resolve(import.meta.dirname, '../..');
|
||||||
|
export function sourceOptions(args) {
|
||||||
|
const values = {};
|
||||||
|
for (let i = 0; i < args.length; i += 2) {
|
||||||
|
if (!['--revision', '--version', '--platform', '--output'].includes(args[i]) || !args[i + 1] || values[args[i]]) throw new Error('Use --revision COMMIT --version VERSION --platform linux/amd64|linux/arm64 --output NEW_DIRECTORY.');
|
||||||
|
values[args[i]] = args[i + 1];
|
||||||
|
}
|
||||||
|
if (!values['--revision'] || values['--revision'].startsWith('-') || !/^[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?$/.test(values['--version'] ?? '') || !['linux/amd64', 'linux/arm64'].includes(values['--platform']) || !values['--output']) throw new Error('Select an explicit source revision, version, Linux platform and new output directory.');
|
||||||
|
return { revision: values['--revision'], version: values['--version'], platform: values['--platform'], output: resolve(values['--output']) };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function buildSourceImages({ run, source, output, revision, version, platform }) {
|
||||||
|
const images = {};
|
||||||
|
for (const role of ['core', 'frontend']) {
|
||||||
|
const iid = join(output, `${role}.iid`);
|
||||||
|
const localTag = `thothii-source-${role}:${randomBytes(16).toString('hex')}`;
|
||||||
|
await run('docker', ['buildx', 'build', '--load', '--tag', localTag, '--platform', platform, '--file', `docker/${role}.Dockerfile`,
|
||||||
|
'--iidfile', iid, '--build-arg', `IMAGE_VERSION=${version}`, '--label', `org.opencontainers.image.revision=${revision}`,
|
||||||
|
'--label', `org.opencontainers.image.version=${version}`, '--provenance=false', '--sbom=false', '.'], { cwd: source, timeout: 45 * 60_000 });
|
||||||
|
const id = readFileSync(iid, 'utf8').trim();
|
||||||
|
if (!/^sha256:[a-f0-9]{64}$/.test(id)) throw new Error('Source build did not produce an immutable local image identity.');
|
||||||
|
// Containerd and classic Docker stores expose different IDs; resolve the local
|
||||||
|
// daemon identity through our unique build tag, then pin that immutable ID.
|
||||||
|
const image = JSON.parse(await run('docker', ['image', 'inspect', '--format', '{{json .}}', localTag], { quiet: true }));
|
||||||
|
if (!/^sha256:[a-f0-9]{64}$/.test(image.Id ?? '') || `${image.Os}/${image.Architecture}` !== platform || image.Config?.Labels?.['org.opencontainers.image.revision'] !== revision || image.Config?.Labels?.['org.opencontainers.image.version'] !== version) throw new Error('Built image identity differs from the selected source.');
|
||||||
|
images[role] = image.Id;
|
||||||
|
}
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function prepareSourceInstallation(options) {
|
||||||
|
// mkdir is exclusive: never replace a bundle or mix an incomplete previous build with new inputs.
|
||||||
|
mkdirSync(options.output, { mode: 0o700 });
|
||||||
|
if (realpathSync(options.output) !== options.output) throw new Error('Use a canonical output path.');
|
||||||
|
const logs = join(options.output, 'logs'); mkdirSync(logs, { mode: 0o700 });
|
||||||
|
const run = commandRunner(logs);
|
||||||
|
let temporary, source;
|
||||||
|
try {
|
||||||
|
const revision = (await run('git', ['rev-parse', '--verify', `${options.revision}^{commit}`], { quiet: true })).trim();
|
||||||
|
if (!/^[a-f0-9]{40}$/.test(revision)) throw new Error('Select a committed source revision.');
|
||||||
|
await run('docker', ['info', '--format', '{{.OSType}}']);
|
||||||
|
await run('docker', ['buildx', 'version']);
|
||||||
|
temporary = realpathSync(mkdtempSync(join(tmpdir(), 'thothii-source-')));
|
||||||
|
source = join(temporary, 'source');
|
||||||
|
await run('git', ['worktree', 'add', '--detach', source, revision]);
|
||||||
|
console.log(`Building explicit source installation ${revision} for ${options.platform}.`);
|
||||||
|
const images = await buildSourceImages({ run, source, output: options.output, revision, version: options.version, platform: options.platform });
|
||||||
|
const compose = parse(readFileSync(join(source, 'compose.yaml'), 'utf8'));
|
||||||
|
const registry = dockerHub();
|
||||||
|
for (const [role, service] of [['catalog', 'catalog-db'], ['qdrant', 'qdrant'], ['embedding', 'embedding']]) {
|
||||||
|
const [name, digest] = compose.services[service].image.split('@');
|
||||||
|
if (!/^sha256:[a-f0-9]{64}$/.test(digest ?? '')) throw new Error('Upstream source images must already be pinned.');
|
||||||
|
let repository = name.replace(/:[^/:]+$/, '').replace(/^docker.io\//, '');
|
||||||
|
if (!repository.includes('/')) repository = `library/${repository}`;
|
||||||
|
images[role] = (await registry.inspect(repository, digest, options.platform, { anonymous: true })).reference;
|
||||||
|
}
|
||||||
|
await run('npm', ['ci'], { cwd: join(source, 'backend'), timeout: 10 * 60_000 });
|
||||||
|
const target = options.platform.replace('/', '-');
|
||||||
|
const sourceTime = (await run('git', ['show', '-s', '--format=%cI', revision], { quiet: true })).trim();
|
||||||
|
await run(process.execPath, [join(repositoryRoot, 'backend/scripts/build-workspace-tools.mjs'), target], {
|
||||||
|
cwd: join(source, 'backend'), env: { ...process.env, THT_BUILD_SOURCE_ROOT: source, THT_BUILD_VERSION: options.version, THT_BUILD_TIME: sourceTime }, timeout: 10 * 60_000,
|
||||||
|
});
|
||||||
|
const bundle = join(options.output, 'bundle'); mkdirSync(bundle, { mode: 0o700 });
|
||||||
|
prepareBundle({ source, destination: bundle, platform: options.platform, version: options.version, revision, images, distribution: 'source' });
|
||||||
|
mkdirSync(join(bundle, 'bin'));
|
||||||
|
for (const executable of ['tht', 'tht-workspace-documents']) {
|
||||||
|
copyFileSync(join(source, 'dist/workspace-tools', target, executable), join(bundle, 'bin', executable));
|
||||||
|
chmodSync(join(bundle, 'bin', executable), 0o755);
|
||||||
|
}
|
||||||
|
await run('docker', ['compose', '-f', join(bundle, 'compose.yaml'), '-f', join(bundle, 'deploy/compose.local.yaml'), '--profile', 'catalog-maintenance', '--profile', 'workspace-maintenance', 'config', '--no-interpolate', '--no-env-resolution', '--format', 'json']);
|
||||||
|
console.log(`Source bundle prepared: ${bundle}. Use its operator for ordinary installation validate, plan and apply on this Docker daemon.`);
|
||||||
|
return bundle;
|
||||||
|
} finally {
|
||||||
|
if (source && existsSync(source)) await run('git', ['worktree', 'remove', '--force', source]).catch(() => {});
|
||||||
|
if (temporary && !existsSync(source ?? '')) rmSync(temporary, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
||||||
|
try { await prepareSourceInstallation(sourceOptions(process.argv.slice(2))); }
|
||||||
|
catch { console.error('Source preparation failed. Inspect the private build logs and use a new output directory to retry; no images were published.'); process.exitCode = 1; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Maintainer-only producer. Consumers download the resulting native bundle.
|
||||||
|
import { spawn } from "node:child_process";
|
||||||
|
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync, existsSync, realpathSync, renameSync, rmSync, statSync, copyFileSync, chmodSync, openSync, closeSync, readdirSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { basename, dirname, join, resolve } from "node:path";
|
||||||
|
import { pathToFileURL } from "node:url";
|
||||||
|
import { parse } from "yaml";
|
||||||
|
import { prepareBundle, sha256 } from "./release-bundle.mjs";
|
||||||
|
import { dockerCredentials, dockerHub } from "./release-registry.mjs";
|
||||||
|
import { giteaHosting } from "./release-hosting.mjs";
|
||||||
|
import { publishVerifiedRelease } from "./release-publication.mjs";
|
||||||
|
|
||||||
|
const repositoryRoot = resolve(import.meta.dirname, "../..");
|
||||||
|
export function optionsFromArgs(args) {
|
||||||
|
const values = {};
|
||||||
|
for (let i = 0; i < args.length; i += 2) {
|
||||||
|
if (!['--revision', '--version', '--namespace', '--platforms', '--output', '--repository'].includes(args[i]) || !args[i + 1] || values[args[i]]) throw new Error("Usage: --revision REF --version VERSION --namespace DOCKER_HUB_NAMESPACE --platforms linux/amd64 --output NEW_OR_MATCHING_DIRECTORY [--repository HTTPS_GITEA_REPO]");
|
||||||
|
values[args[i]] = args[i + 1];
|
||||||
|
}
|
||||||
|
if (!values['--revision'] || values['--revision'].startsWith('-') || !/^[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?$/.test(values['--version'] ?? '') || !/^[a-z0-9][a-z0-9_-]{1,38}$/.test(values['--namespace'] ?? '') || !values['--output']) throw new Error("Supply an explicit source revision, semantic release version, Docker Hub namespace and output directory.");
|
||||||
|
const platforms = (values['--platforms'] ?? '').split(',');
|
||||||
|
if (!platforms.length || new Set(platforms).size !== platforms.length || platforms.some((p) => !['linux/amd64', 'linux/arm64'].includes(p))) throw new Error("Select explicit Linux image platforms; begin with linux/amd64 for Windows/WSL2 and Omarchy.");
|
||||||
|
const repository = values['--repository'] ?? 'https://git.tylconsulting.it/mptyl/ThothII';
|
||||||
|
const url = new URL(repository);
|
||||||
|
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash || !/^\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(url.pathname)) throw new Error("Use a credential-free HTTPS Gitea owner/repository URL.");
|
||||||
|
return { revision: values['--revision'], version: values['--version'], namespace: values['--namespace'], platforms: platforms.sort(), output: resolve(values['--output']), repository };
|
||||||
|
}
|
||||||
|
export function commandRunner(logs) {
|
||||||
|
let sequence = 0;
|
||||||
|
return async (command, args, { cwd = repositoryRoot, input = '', env = process.env, quiet = false, timeout = 120_000 } = {}) => {
|
||||||
|
const log = join(logs, `${++sequence}-${basename(command)}.log`);
|
||||||
|
return new Promise((accept, reject) => {
|
||||||
|
if (process.platform === 'win32') { reject(new Error('Run the release producer on Linux, WSL2 or macOS.')); return; }
|
||||||
|
const child = spawn(command, args, { cwd, env, detached: true, stdio: ['pipe', 'pipe', 'pipe'] });
|
||||||
|
const stdout = [], stderr = []; let size = 0, overflow = false, settled = false, reapTimer;
|
||||||
|
const terminate = () => {
|
||||||
|
if (overflow) return;
|
||||||
|
overflow = true;
|
||||||
|
try { process.kill(-child.pid, 'SIGKILL'); } catch { child.kill('SIGKILL'); }
|
||||||
|
// An escaped descendant must never retain our pipes indefinitely.
|
||||||
|
reapTimer = setTimeout(() => { child.stdout.destroy(); child.stderr.destroy(); finish(-1); }, 500);
|
||||||
|
};
|
||||||
|
const timer = setTimeout(terminate, timeout);
|
||||||
|
const collect = (chunks) => (data) => { size += data.length; if (size > 64 * 2 ** 20) terminate(); else chunks.push(data); };
|
||||||
|
child.stdout.on('data', collect(stdout)); child.stderr.on('data', collect(stderr));
|
||||||
|
child.stdin.on('error', () => {}); child.stdin.end(input);
|
||||||
|
child.on('error', () => { settled = true; clearTimeout(timer); clearTimeout(reapTimer); reject(new Error(`Required maintainer command ${basename(command)} is unavailable.`)); });
|
||||||
|
function finish(code) {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer); clearTimeout(reapTimer);
|
||||||
|
if (!quiet) writeFileSync(log, Buffer.concat([...stdout, ...stderr]), { mode: 0o600 });
|
||||||
|
if (code !== 0 || overflow) reject(new Error(`${basename(command)} failed${quiet ? '.' : `; inspect private log ${log}`}`));
|
||||||
|
else accept(Buffer.concat(stdout).toString());
|
||||||
|
}
|
||||||
|
child.on('close', finish);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function acquireOutput(output) {
|
||||||
|
if (!existsSync(output)) mkdirSync(output, { mode: 0o700 });
|
||||||
|
if (realpathSync(output) !== output || !statSync(output).isDirectory() || (statSync(output).mode & 0o077)) throw new Error("Use a canonical owner-only output directory.");
|
||||||
|
if (!existsSync(join(output, 'publication-state.json')) && readdirSync(output).length) throw new Error("Choose an empty output directory or the matching previous publication directory.");
|
||||||
|
const lock = join(output, '.publisher.lock');
|
||||||
|
if (existsSync(lock)) {
|
||||||
|
const pid = Number(readFileSync(lock, 'utf8'));
|
||||||
|
if (!Number.isInteger(pid) || pid <= 0) throw new Error("Inspect the incomplete publisher lock before retrying.");
|
||||||
|
let alive = true;
|
||||||
|
try { process.kill(pid, 0); } catch (error) { if (error.code === 'ESRCH') alive = false; }
|
||||||
|
if (alive) throw new Error("Another publisher owns this output directory.");
|
||||||
|
rmSync(lock);
|
||||||
|
}
|
||||||
|
const fd = openSync(lock, 'wx', 0o600); writeFileSync(fd, String(process.pid)); closeSync(fd);
|
||||||
|
return () => rmSync(lock, { force: true });
|
||||||
|
}
|
||||||
|
export async function publishInstallation(options) {
|
||||||
|
const unlock = acquireOutput(options.output);
|
||||||
|
const logs = join(options.output, 'logs'); mkdirSync(logs, { recursive: true, mode: 0o700 });
|
||||||
|
const run = commandRunner(logs);
|
||||||
|
let worktree, temporary;
|
||||||
|
try {
|
||||||
|
const revision = (await run('git', ['rev-parse', '--verify', `${options.revision}^{commit}`], { quiet: true })).trim();
|
||||||
|
if (!/^[a-f0-9]{40}$/.test(revision)) throw new Error("Source revision is not a commit.");
|
||||||
|
const identity = { revision, version: options.version, namespace: options.namespace, platforms: options.platforms, repository: options.repository };
|
||||||
|
const statePath = join(options.output, 'publication-state.json');
|
||||||
|
let state = { identity };
|
||||||
|
if (existsSync(statePath)) {
|
||||||
|
state = JSON.parse(readFileSync(statePath, 'utf8'));
|
||||||
|
if (JSON.stringify(state.identity) !== JSON.stringify(identity)) throw new Error("Output directory belongs to a different release; choose a new directory.");
|
||||||
|
}
|
||||||
|
const save = () => { const temp = statePath + '.tmp'; writeFileSync(temp, JSON.stringify(state, null, 2) + '\n', { mode: 0o600 }); renameSync(temp, statePath); };
|
||||||
|
save();
|
||||||
|
console.log(`Release ${identity.version}: ${identity.namespace}, ${identity.platforms.join(',')}, source ${revision}`);
|
||||||
|
await run('docker', ['info', '--format', '{{.OSType}}']);
|
||||||
|
await run('docker', ['buildx', 'version']);
|
||||||
|
const registry = dockerHub(await dockerCredentials(run));
|
||||||
|
const hosting = await giteaHosting({ run, repository: options.repository, identity, body: `Installer prerelease for ${identity.platforms.join(', ')}.\n\nImages: docker.io/${identity.namespace}/thothii-core:${identity.version} and docker.io/${identity.namespace}/thothii-frontend:${identity.version}.\n\nDownload the native operator bundle and SHA256SUMS.txt below. This release supplies images, document validation, preflight, non-interactive platform apply, prepared binding import and workspace/runtime readiness checks. Destructive schema review remains a human decision. Windows/Omarchy/macOS and human-reviewed question acceptance remain subsequent steps. No example databases, credentials or user workspace data are included.` });
|
||||||
|
async function prepare() {
|
||||||
|
if (state.assets) {
|
||||||
|
const names = [...identity.platforms.map((platform) => `thothii-${identity.version}-${platform.replace('/', '-')}.tar.gz`), 'SHA256SUMS.txt'];
|
||||||
|
if (state.assets.length !== names.length) throw new Error("Cached artifact set is incomplete.");
|
||||||
|
for (const asset of state.assets) if (!names.includes(asset.name) || asset.path !== join(options.output, asset.name) || !existsSync(asset.path) || sha256(readFileSync(asset.path)) !== asset.sha256) throw new Error("Previously built release artifact changed; do not overwrite an immutable version.");
|
||||||
|
for (const [platform, images] of Object.entries(state.images)) for (const reference of Object.values(images)) {
|
||||||
|
const [repository, digest] = reference.replace(/^docker.io\//, '').split('@');
|
||||||
|
await registry.inspect(repository, digest, platform, { anonymous: true });
|
||||||
|
}
|
||||||
|
return state.assets;
|
||||||
|
}
|
||||||
|
temporary = realpathSync(mkdtempSync(join(tmpdir(), 'thothii-release-')));
|
||||||
|
worktree = join(temporary, 'source');
|
||||||
|
await run('git', ['worktree', 'add', '--detach', worktree, revision]);
|
||||||
|
const sourceCompose = parse(readFileSync(join(worktree, 'compose.yaml'), 'utf8'));
|
||||||
|
for (const role of ['core', 'frontend']) {
|
||||||
|
console.log(`Preparing public repository ${identity.namespace}/thothii-${role}`);
|
||||||
|
await registry.ensurePublic(identity.namespace, `thothii-${role}`);
|
||||||
|
let existing = null;
|
||||||
|
for (const platform of identity.platforms) {
|
||||||
|
const image = await registry.inspect(`${identity.namespace}/thothii-${role}`, identity.version, platform, { allowMissing: true });
|
||||||
|
if (image && (image.labels['org.opencontainers.image.revision'] !== revision || image.labels['org.opencontainers.image.version'] !== identity.version)) throw new Error("Image tag already belongs to another immutable build; select a new release version.");
|
||||||
|
existing = existing || image;
|
||||||
|
}
|
||||||
|
if (!existing) {
|
||||||
|
console.log(`Building and publishing ${role} (${identity.platforms.join(', ')})`);
|
||||||
|
await run('docker', ['buildx', 'build', '--platform', identity.platforms.join(','), '--file', `docker/${role}.Dockerfile`, '--tag', `docker.io/${identity.namespace}/thothii-${role}:${identity.version}`, '--build-arg', `IMAGE_VERSION=${identity.version}`, '--label', `org.opencontainers.image.revision=${revision}`, '--label', `org.opencontainers.image.source=${identity.repository}`, '--provenance=false', '--sbom=false', '--push', '.'], { cwd: worktree, timeout: 45 * 60_000 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.images = {};
|
||||||
|
for (const platform of identity.platforms) {
|
||||||
|
const images = {};
|
||||||
|
for (const role of ['core', 'frontend']) images[role] = (await registry.inspect(`${identity.namespace}/thothii-${role}`, identity.version, platform, { anonymous: true })).reference;
|
||||||
|
for (const [role, service] of [['catalog', 'catalog-db'], ['qdrant', 'qdrant'], ['embedding', 'embedding']]) {
|
||||||
|
const [named, digest] = sourceCompose.services[service].image.split('@');
|
||||||
|
let repository = named.replace(/:[^/:]+$/, '').replace(/^docker.io\//, '');
|
||||||
|
if (!repository.includes('/')) repository = 'library/' + repository;
|
||||||
|
images[role] = (await registry.inspect(repository, digest, platform, { anonymous: true })).reference;
|
||||||
|
}
|
||||||
|
state.images[platform] = images;
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
console.log('Building native operator bundles from the selected source');
|
||||||
|
await run('npm', ['ci'], { cwd: join(worktree, 'backend'), timeout: 10 * 60_000 });
|
||||||
|
const sourceTime = (await run('git', ['show', '-s', '--format=%cI', revision], { quiet: true })).trim();
|
||||||
|
const targets = identity.platforms.map((platform) => platform.replace('/', '-'));
|
||||||
|
await run('node', [join(repositoryRoot, 'backend/scripts/build-workspace-tools.mjs'), ...targets], { cwd: join(worktree, 'backend'), env: { ...process.env, THT_BUILD_SOURCE_ROOT: worktree, THT_BUILD_VERSION: identity.version, THT_BUILD_TIME: sourceTime }, timeout: 10 * 60_000 });
|
||||||
|
const assets = [];
|
||||||
|
for (const platform of identity.platforms) {
|
||||||
|
const target = platform.replace('/', '-');
|
||||||
|
const name = `thothii-${identity.version}-${target}`;
|
||||||
|
const bundle = join(options.output, name);
|
||||||
|
if (existsSync(bundle)) rmSync(bundle, { recursive: true }); // owned staging, never an installed runtime
|
||||||
|
mkdirSync(bundle);
|
||||||
|
prepareBundle({ source: worktree, destination: bundle, platform, version: identity.version, revision, images: state.images[platform] });
|
||||||
|
mkdirSync(join(bundle, 'bin'));
|
||||||
|
for (const executable of ['tht', 'tht-workspace-documents']) {
|
||||||
|
copyFileSync(join(worktree, 'dist/workspace-tools', target, executable), join(bundle, 'bin', executable));
|
||||||
|
chmodSync(join(bundle, 'bin', executable), 0o755);
|
||||||
|
}
|
||||||
|
// Resolve source-independent resource/config shape without any operator credentials.
|
||||||
|
await run('docker', ['compose', '-f', join(bundle, 'compose.yaml'), '-f', join(bundle, 'deploy/compose.local.yaml'), '--profile', 'catalog-maintenance', '--profile', 'workspace-maintenance', 'config', '--no-interpolate', '--no-env-resolution', '--format', 'json']);
|
||||||
|
const archive = join(options.output, name + '.tar.gz');
|
||||||
|
await run('tar', ['-czf', archive, '-C', options.output, name]);
|
||||||
|
assets.push({ name: basename(archive), path: archive, bytes: statSync(archive).size, sha256: sha256(readFileSync(archive)) });
|
||||||
|
}
|
||||||
|
const sums = join(options.output, 'SHA256SUMS.txt');
|
||||||
|
writeFileSync(sums, assets.map((asset) => `${asset.sha256} ${asset.name}\n`).join(''));
|
||||||
|
assets.push({ name: 'SHA256SUMS.txt', path: sums, bytes: statSync(sums).size, sha256: sha256(readFileSync(sums)) });
|
||||||
|
// An empty Docker configuration proves the consumer can pull without publisher credentials.
|
||||||
|
const publicConfig = join(temporary, 'public-docker'); mkdirSync(publicConfig);
|
||||||
|
for (const [platform, images] of Object.entries(state.images)) {
|
||||||
|
for (const reference of Object.values(images)) {
|
||||||
|
console.log(`Verifying anonymous pull ${reference.split('@')[0]} (${platform})`);
|
||||||
|
await run('docker', ['--config', publicConfig, 'pull', '--platform', platform, reference], { timeout: 20 * 60_000 });
|
||||||
|
}
|
||||||
|
console.log(`Smoke checking published images (${platform})`);
|
||||||
|
await run('docker', ['run', '--rm', '--platform', platform, '--network', 'none', '--entrypoint', '/bin/sh', images.core, '-ec', 'test "$(pi --version)" = "$PI_VERSION"; tht --help >/dev/null; test -f /app/backend/dist/catalog/migrate.js; test -x /app/docker/workspace-maintenance-entrypoint.sh; test -f /app/docker/catalog-migrate.sh; test ! -e /run/secrets/thothii.secrets'], { timeout: 5 * 60_000 });
|
||||||
|
await run('docker', ['run', '--rm', '--platform', platform, '--network', 'none', '--entrypoint', '/usr/local/bin/frontend-config-smoke', images.frontend], { timeout: 60_000 });
|
||||||
|
}
|
||||||
|
state.assets = assets; save();
|
||||||
|
return assets;
|
||||||
|
}
|
||||||
|
const published = await publishVerifiedRelease({ hosting, prepare });
|
||||||
|
state.releaseURL = published.html_url; state.complete = true; save();
|
||||||
|
console.log(`Published and verified: ${published.html_url}`);
|
||||||
|
return published;
|
||||||
|
} finally {
|
||||||
|
if (worktree && existsSync(worktree)) await run('git', ['worktree', 'remove', '--force', worktree]).catch(() => {});
|
||||||
|
if (temporary && !existsSync(worktree ?? '')) rmSync(temporary, { recursive: true, force: true });
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
||||||
|
try { await publishInstallation(optionsFromArgs(process.argv.slice(2))); }
|
||||||
|
catch (error) { console.error(error instanceof SyntaxError ? 'Invalid release metadata; no secret values are printed.' : error.message); process.exitCode = 1; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { mkdirSync, readFileSync, writeFileSync, lstatSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { parse, stringify } from "yaml";
|
||||||
|
|
||||||
|
export const serviceRoles = Object.freeze({ core: "core", frontend: "frontend", "catalog-db": "catalog", "catalog-migrate": "core", "workspace-maintenance": "core", qdrant: "qdrant", embedding: "embedding", "embedding-model-init": "embedding" });
|
||||||
|
export const sha256 = (data) => createHash("sha256").update(data).digest("hex");
|
||||||
|
|
||||||
|
/** Only distribution assets enter the bundle: never a checkout, environment file or workspace. */
|
||||||
|
export function prepareBundle({ source, destination, platform, version, revision, images, distribution = "prebuilt" }) {
|
||||||
|
if (!["prebuilt", "source"].includes(distribution)) throw new Error("Unknown installation distribution.");
|
||||||
|
const compose = parse(readFileSync(join(source, "compose.yaml"), "utf8"));
|
||||||
|
if (Object.keys(compose.services).sort().join() !== Object.keys(serviceRoles).sort().join()) throw new Error("Release service contract changed; review packaging before publishing.");
|
||||||
|
for (const [name, role] of Object.entries(serviceRoles)) {
|
||||||
|
const local = distribution === "source" && ["core", "frontend"].includes(role);
|
||||||
|
const pattern = local ? /^sha256:[a-f0-9]{64}$/ : /^docker\.io\/[a-z0-9][a-z0-9._/-]*@sha256:[a-f0-9]{64}$/;
|
||||||
|
if (!pattern.test(images[role] ?? "")) throw new Error("Release requires immutable image references for its distribution.");
|
||||||
|
delete compose.services[name].build;
|
||||||
|
delete compose.services[name].pull_policy;
|
||||||
|
compose.services[name].image = images[role];
|
||||||
|
compose.services[name].platform = platform;
|
||||||
|
}
|
||||||
|
const files = {};
|
||||||
|
const write = (name, data) => {
|
||||||
|
mkdirSync(dirname(join(destination, name)), { recursive: true });
|
||||||
|
writeFileSync(join(destination, name), data);
|
||||||
|
files[name] = sha256(data);
|
||||||
|
};
|
||||||
|
write("compose.yaml", stringify(compose));
|
||||||
|
for (const name of ["deploy/compose.local.yaml", "deploy/compose.git-https.yaml", "deploy/compose.git-ssh.yaml", "docker/catalog-db-init.sql", "docker/embedding-model-init.sh"]) {
|
||||||
|
const path = join(source, name);
|
||||||
|
if (!lstatSync(path).isFile()) throw new Error("Release asset must be a regular tracked file.");
|
||||||
|
write(name, readFileSync(path));
|
||||||
|
}
|
||||||
|
// Any future source bind mount must be deliberately added to the asset allowlist.
|
||||||
|
for (const service of Object.values(compose.services)) {
|
||||||
|
for (const volume of service.volumes ?? []) {
|
||||||
|
const sourcePath = typeof volume === "string" ? volume.split(":")[0] : volume.type === "bind" ? volume.source : undefined;
|
||||||
|
if (sourcePath?.startsWith(".") && !files[sourcePath.replace(/^\.\//, "")]) throw new Error("Source bind mount is missing from the release bundle.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const manifest = { schema_version: 1, version, revision, validator_protocol: 1,
|
||||||
|
...(distribution === "source" ? { distribution } : {}),
|
||||||
|
requirements: { cpus: 2, memory_bytes: 4 * 2 ** 30, disk_bytes: 10 * 2 ** 30 },
|
||||||
|
components: ["pi", "catalog-migrations", "workspace-maintenance"],
|
||||||
|
images: Object.fromEntries(Object.entries(images).map(([role, reference]) => [role, { [platform]: reference }])),
|
||||||
|
files, compose: ["compose.yaml", "deploy/compose.local.yaml"] };
|
||||||
|
writeFileSync(join(destination, "release-manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
|
||||||
|
writeFileSync(join(destination, "README.md"), `# ThothII ${version} — ${platform}
|
||||||
|
|
||||||
|
Source / Sorgente: ${revision}
|
||||||
|
|
||||||
|
Distribution / Distribuzione: ${distribution}. ${distribution === 'source' ? 'Application images are local to the producer Docker daemon; this bundle is not a public image release. Le immagini applicative sono locali al daemon Docker del produttore.' : 'Application images are downloaded from Docker Hub. Le immagini applicative vengono scaricate da Docker Hub.'}
|
||||||
|
|
||||||
|
This prerelease provides images, document/preflight tools, non-interactive platform apply, prepared binding import and workspace/runtime readiness checks. A pending destructive schema review stops apply for a human decision. Windows/Omarchy/macOS and human-reviewed question acceptance remain separate; this is not a certified complete installation.
|
||||||
|
Questa prerelease fornisce immagini, preparazione/preflight, avvio non interattivo, import dei binding e controlli di readiness workspace/runtime. Una revisione distruttiva dello schema ferma apply per una decisione umana. Collaudi Windows/Omarchy/macOS e domanda con revisione umana restano separati: non è ancora un'installazione completa certificata.
|
||||||
|
|
||||||
|
Use bin/tht and its sibling bin/tht-workspace-documents together; no Node, Python, Bun or application checkout is required on the consumer host.
|
||||||
|
Windows: use the Linux amd64 bundle inside Ubuntu WSL2, not a native Windows shell.
|
||||||
|
Run as the same non-root operator that prepared the documents, with access to local Docker.
|
||||||
|
|
||||||
|
1. bin/tht workspace prepare --directory NEW_WORKSPACE --id practice --name Practice
|
||||||
|
2. bin/tht workspace validate --directory WORKSPACE
|
||||||
|
3. bin/tht installation prepare --directory NEW_PRIVATE_INSTALLATION
|
||||||
|
4. bin/tht installation preflight --directory INSTALLATION --release ABSOLUTE_RELEASE_DIR/release-manifest.json
|
||||||
|
5. Complete the commented documents, generate technical credentials explicitly, then run installation validate and installation plan with --installation ABSOLUTE_INSTALLATION_FILE.
|
||||||
|
6. bin/tht --installation ABSOLUTE_INSTALLATION_FILE installation apply --plan ABSOLUTE_PLAN --json
|
||||||
|
|
||||||
|
Images are pinned by digest; runtime credentials and user workspaces are never bundled.
|
||||||
|
Consult the accompanying IT/EN guides for prepared documents, retry behavior and mandatory runtime checks.
|
||||||
|
`);
|
||||||
|
for (const [name, target] of [["standalone-manual-it.md", "GUIDE-IT.md"], ["standalone-manual-en.md", "GUIDE-EN.md"], ["installation-preflight.md", "PREFLIGHT.md"]]) writeFileSync(join(destination, target), readFileSync(join(source, "docs/install", name)));
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { test } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { mkdtempSync, readFileSync, rmSync, existsSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { resolve, join } from "node:path";
|
||||||
|
import { parse } from "yaml";
|
||||||
|
import { prepareBundle } from "./release-bundle.mjs";
|
||||||
|
|
||||||
|
test("consumer bundle pins every service and carries all source bind resources", () => {
|
||||||
|
const output = mkdtempSync(join(tmpdir(), "thoth-release-test-"));
|
||||||
|
const images = Object.fromEntries(["core", "frontend", "catalog", "qdrant", "embedding"].map((role) => [role, `docker.io/tylconsulting/${role}@sha256:${"a".repeat(64)}`]));
|
||||||
|
try {
|
||||||
|
prepareBundle({ source: resolve(import.meta.dirname, "../.."), destination: output, platform: "linux/amd64", version: "0.1.0-install-preview.1", revision: "b".repeat(40), images });
|
||||||
|
const manifest = JSON.parse(readFileSync(join(output, "release-manifest.json")));
|
||||||
|
const compose = parse(readFileSync(join(output, "compose.yaml"), "utf8"));
|
||||||
|
assert.equal(compose.services.core.image, images.core);
|
||||||
|
assert.equal(compose.services["catalog-migrate"].image, images.core);
|
||||||
|
assert.equal(compose.services["workspace-maintenance"].image, images.core);
|
||||||
|
assert.equal(compose.services["embedding-model-init"].image, images.embedding);
|
||||||
|
for (const service of Object.values(compose.services)) {
|
||||||
|
assert.equal(service.build, undefined);
|
||||||
|
assert.equal(service.pull_policy, undefined);
|
||||||
|
assert.equal(service.platform, "linux/amd64");
|
||||||
|
for (const volume of service.volumes ?? []) {
|
||||||
|
if (typeof volume === "string" && volume.startsWith("./")) assert.ok(existsSync(join(output, volume.split(":")[0])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.equal(manifest.validator_protocol, 1);
|
||||||
|
assert.deepEqual(manifest.compose, ["compose.yaml", "deploy/compose.local.yaml"]);
|
||||||
|
assert.ok(manifest.files["docker/catalog-db-init.sql"]);
|
||||||
|
assert.ok(manifest.files["docker/embedding-model-init.sh"]);
|
||||||
|
assert.ok(!existsSync(join(output, "backend")));
|
||||||
|
assert.ok(!existsSync(join(output, "harness")));
|
||||||
|
} finally { rmSync(output, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { boundedFetch, readLimited } from "./release-registry.mjs";
|
||||||
|
import { sha256 } from "./release-bundle.mjs";
|
||||||
|
|
||||||
|
export async function giteaHosting({ run, repository, identity, body }) {
|
||||||
|
const remote = new URL(repository);
|
||||||
|
const credential = await run("git", ["credential", "fill"], { input: `protocol=https\nhost=${remote.host}\n\n`, quiet: true, env: { ...process.env, GIT_TERMINAL_PROMPT: "0" } });
|
||||||
|
const fields = Object.fromEntries(credential.trim().split("\n").map((line) => { const at = line.indexOf("="); return [line.slice(0, at), line.slice(at + 1)]; }));
|
||||||
|
if (!fields.username || !fields.password) throw new Error("Gitea publishing credentials are unavailable in the Git credential store.");
|
||||||
|
const authorization = `Basic ${Buffer.from(`${fields.username}:${fields.password}`).toString("base64")}`;
|
||||||
|
const api = `${remote.origin}/api/v1/repos${remote.pathname.replace(/\.git$/, "")}`;
|
||||||
|
const marker = `<!-- thothii-release:${JSON.stringify(identity)} -->`;
|
||||||
|
const tag = `installation-v${identity.version}`;
|
||||||
|
async function request(path, options = {}, allowMissing = false) {
|
||||||
|
const response = await boundedFetch(api + path, { ...options, headers: { Authorization: authorization, ...options.headers } }, 120_000);
|
||||||
|
if (allowMissing && response.status === 404) return null;
|
||||||
|
if (!response.ok) throw new Error(`Gitea release operation failed (HTTP ${response.status}).`);
|
||||||
|
const bytes = await readLimited(response, 4 * 2 ** 20);
|
||||||
|
try { return JSON.parse(bytes.toString()); } catch { throw new Error("Gitea returned invalid release metadata."); }
|
||||||
|
}
|
||||||
|
const json = (method, value) => ({ method, headers: { "Content-Type": "application/json" }, body: JSON.stringify(value) });
|
||||||
|
async function verifyTag(required = false) {
|
||||||
|
const existing = await request(`/tags/${encodeURIComponent(tag)}`, {}, true);
|
||||||
|
if ((!existing && required) || (existing && existing.commit?.sha !== identity.revision)) throw new Error("Release Git tag does not match the requested source revision.");
|
||||||
|
}
|
||||||
|
async function assets(release) { return request(`/releases/${release.id}/assets`); }
|
||||||
|
async function verifyAsset(asset, expected, publicRead) {
|
||||||
|
const url = new URL(asset.browser_download_url);
|
||||||
|
if (url.origin !== remote.origin) throw new Error("Unexpected release asset origin.");
|
||||||
|
const response = await boundedFetch(url, { headers: publicRead ? {} : { Authorization: authorization } }, 120_000);
|
||||||
|
if (!response.ok || sha256(await readLimited(response, expected.bytes + 1)) !== expected.sha256) throw new Error("Published release asset does not match its verified checksum.");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
async open() {
|
||||||
|
const info = await request("");
|
||||||
|
if (info.private || !info.permissions?.push) throw new Error("Release hosting must be a public Gitea repository with publication rights.");
|
||||||
|
await verifyTag();
|
||||||
|
const existing = await request(`/releases/tags/${encodeURIComponent(tag)}`, {}, true);
|
||||||
|
if (existing) {
|
||||||
|
if (!existing.body?.includes(marker)) throw new Error("Release version already belongs to another source or publication identity; it will not be overwritten.");
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
return request("/releases", json("POST", { tag_name: tag, target_commitish: identity.revision, name: `ThothII ${identity.version}`, body: `${body}\n\n${marker}`, draft: true, prerelease: true }));
|
||||||
|
},
|
||||||
|
async upload(release, asset) {
|
||||||
|
const matching = (await assets(release)).filter((item) => item.name === asset.name);
|
||||||
|
if (matching.length > 1) throw new Error("Ambiguous release assets; no published files were replaced.");
|
||||||
|
if (matching.length === 1) { await verifyAsset(matching[0], asset, false); return; }
|
||||||
|
const data = readFileSync(asset.path);
|
||||||
|
if (sha256(data) !== asset.sha256) throw new Error("Local release asset changed before upload.");
|
||||||
|
const form = new FormData(); form.append("attachment", new Blob([data]), asset.name);
|
||||||
|
await request(`/releases/${release.id}/assets?name=${encodeURIComponent(asset.name)}`, { method: "POST", body: form });
|
||||||
|
},
|
||||||
|
async verify(release, expected, publicRead) {
|
||||||
|
await verifyTag(publicRead);
|
||||||
|
const uploaded = await assets(release);
|
||||||
|
if (uploaded.length !== expected.length) throw new Error("Release asset set is incomplete or contains unexpected files.");
|
||||||
|
for (const asset of expected) {
|
||||||
|
const matching = uploaded.filter((item) => item.name === asset.name);
|
||||||
|
if (matching.length !== 1) throw new Error("Release asset missing or ambiguous.");
|
||||||
|
await verifyAsset(matching[0], asset, publicRead);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async publish(release) {
|
||||||
|
await verifyTag();
|
||||||
|
return request(`/releases/${release.id}`, json("PATCH", { draft: false }));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { test } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { giteaHosting } from './release-hosting.mjs';
|
||||||
|
|
||||||
|
test('release hosting refuses a pre-existing Git tag on another commit', async () => {
|
||||||
|
const fetch = globalThis.fetch;
|
||||||
|
const revision = 'a'.repeat(40);
|
||||||
|
let writes = 0;
|
||||||
|
globalThis.fetch = async (url, options) => {
|
||||||
|
if (options.method) { writes++; return Response.json({ id: 1, draft: true }); }
|
||||||
|
if (String(url).includes('/releases/tags/')) return new Response('', { status: 404 });
|
||||||
|
if (String(url).includes('/tags/installation-v')) return Response.json({ commit: { sha: 'b'.repeat(40) } });
|
||||||
|
return Response.json({ private: false, permissions: { push: true } });
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const hosting = await giteaHosting({ run: async () => 'username=test\npassword=test\n', repository: 'https://example.test/owner/repo', identity: { revision, version: '1.0.0' }, body: '' });
|
||||||
|
await assert.rejects(hosting.open(), /tag.*revision/i);
|
||||||
|
assert.equal(writes, 0);
|
||||||
|
} finally { globalThis.fetch = fetch; }
|
||||||
|
});
|
||||||
|
|
||||||
|
test('matching Git tag is accepted and verified again before publishing', async () => {
|
||||||
|
const fetch = globalThis.fetch;
|
||||||
|
const identity = { revision: 'a'.repeat(40), version: '1.0.0' };
|
||||||
|
let sha = identity.revision;
|
||||||
|
let writes = 0;
|
||||||
|
globalThis.fetch = async (url, options) => {
|
||||||
|
if (options.method) { writes++; return Response.json({ id: 1, draft: false }); }
|
||||||
|
if (String(url).includes('/releases/tags/')) return Response.json({ id: 1, draft: true, body: `<!-- thothii-release:${JSON.stringify(identity)} -->` });
|
||||||
|
if (String(url).includes('/tags/')) return Response.json({ commit: { sha } });
|
||||||
|
if (String(url).endsWith('/assets')) return Response.json([]);
|
||||||
|
return Response.json({ private: false, permissions: { push: true } });
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const hosting = await giteaHosting({ run: async () => 'username=test\npassword=test\n', repository: 'https://example.test/owner/repo', identity, body: '' });
|
||||||
|
const release = await hosting.open();
|
||||||
|
await hosting.verify(release, [], false);
|
||||||
|
sha = 'b'.repeat(40);
|
||||||
|
await assert.rejects(hosting.verify(release, [], false), /tag.*revision/i);
|
||||||
|
await assert.rejects(hosting.publish(release), /tag.*revision/i);
|
||||||
|
assert.equal(writes, 0);
|
||||||
|
} finally { globalThis.fetch = fetch; }
|
||||||
|
});
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { test } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdtempSync, rmSync } from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { commandRunner } from './publish-installation.mjs';
|
||||||
|
|
||||||
|
test('publisher timeout terminates descendants that retain output pipes', async () => {
|
||||||
|
const logs = mkdtempSync(join(tmpdir(), 'release-process-test-'));
|
||||||
|
try {
|
||||||
|
const started = Date.now();
|
||||||
|
await assert.rejects(commandRunner(logs)(process.execPath, ['-e', `
|
||||||
|
require('child_process').spawn(process.execPath, ['-e', 'setTimeout(() => {}, 2500)'], {stdio: 'inherit'});
|
||||||
|
setTimeout(() => {}, 2500);
|
||||||
|
`], { timeout: 250, quiet: true }));
|
||||||
|
assert.ok(Date.now() - started < 1800, 'timeout must not wait for the descendant to exit naturally');
|
||||||
|
} finally { rmSync(logs, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/** Drafts are the publication boundary. A partial build/upload is never a consumer release. */
|
||||||
|
export async function publishVerifiedRelease({ hosting, prepare }) {
|
||||||
|
const release = await hosting.open();
|
||||||
|
const assets = await prepare();
|
||||||
|
if (!release.draft) {
|
||||||
|
await hosting.verify(release, assets, true);
|
||||||
|
return release;
|
||||||
|
}
|
||||||
|
for (const asset of assets) await hosting.upload(release, asset);
|
||||||
|
await hosting.verify(release, assets, false);
|
||||||
|
const published = await hosting.publish(release);
|
||||||
|
await hosting.verify(published, assets, true);
|
||||||
|
return published;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { test } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { publishVerifiedRelease } from "./release-publication.mjs";
|
||||||
|
|
||||||
|
test("an interrupted preparation stays draft and retry publishes only after every artifact verifies", async () => {
|
||||||
|
const events = [];
|
||||||
|
let failing = true;
|
||||||
|
const hosting = {
|
||||||
|
open: async () => ({ id: 7, draft: true }),
|
||||||
|
upload: async (_draft, asset) => events.push(`upload:${asset.name}`),
|
||||||
|
verify: async (_draft, assets, publicRead) => events.push(`verify:${publicRead}:${assets.length}`),
|
||||||
|
publish: async () => { events.push("publish"); return { html_url: "https://example.test/release" }; },
|
||||||
|
};
|
||||||
|
const prepare = async () => {
|
||||||
|
if (failing) throw new Error("frontend build unavailable");
|
||||||
|
return [{ name: "bundle.tar.gz" }, { name: "SHA256SUMS" }];
|
||||||
|
};
|
||||||
|
await assert.rejects(publishVerifiedRelease({ hosting, prepare }), /frontend/);
|
||||||
|
assert.deepEqual(events, []);
|
||||||
|
failing = false;
|
||||||
|
await publishVerifiedRelease({ hosting, prepare });
|
||||||
|
assert.deepEqual(events, ["upload:bundle.tar.gz", "upload:SHA256SUMS", "verify:false:2", "publish", "verify:true:2"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a published version is verified without replacing any asset", async () => {
|
||||||
|
const events = [];
|
||||||
|
await publishVerifiedRelease({ prepare: async () => [{ name: "bundle.tar.gz" }], hosting: {
|
||||||
|
open: async () => ({ id: 7, draft: false }),
|
||||||
|
upload: async () => { throw new Error("overwrote a published version"); },
|
||||||
|
publish: async () => { throw new Error("republished a version"); },
|
||||||
|
verify: async (_release, _assets, publicRead) => events.push(publicRead),
|
||||||
|
} });
|
||||||
|
assert.deepEqual(events, [true]);
|
||||||
|
});
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { homedir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { sha256 } from "./release-bundle.mjs";
|
||||||
|
|
||||||
|
const accept = "application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json";
|
||||||
|
export async function boundedFetch(url, options = {}, timeout = 30_000) {
|
||||||
|
try { return await fetch(url, { ...options, redirect: options.redirect ?? "error", signal: AbortSignal.timeout(timeout) }); }
|
||||||
|
catch { throw new Error("Release network request failed; retry with the same output directory."); }
|
||||||
|
}
|
||||||
|
export async function readLimited(response, maximum) {
|
||||||
|
const chunks = []; let size = 0;
|
||||||
|
for await (const chunk of response.body) { size += chunk.length; if (size > maximum) throw new Error("Release response exceeded its bound."); chunks.push(chunk); }
|
||||||
|
return Buffer.concat(chunks);
|
||||||
|
}
|
||||||
|
async function jsonResponse(response, description) {
|
||||||
|
if (!response.ok) throw new Error(`${description} refused (HTTP ${response.status}).`);
|
||||||
|
const bytes = await readLimited(response, 4 * 2 ** 20);
|
||||||
|
try { return { bytes, value: JSON.parse(bytes.toString()) }; }
|
||||||
|
catch { throw new Error("Release service returned invalid metadata."); }
|
||||||
|
}
|
||||||
|
export async function dockerCredentials(run) {
|
||||||
|
const config = JSON.parse(readFileSync(join(process.env.DOCKER_CONFIG || join(homedir(), ".docker"), "config.json"), "utf8"));
|
||||||
|
const server = "https://index.docker.io/v1/";
|
||||||
|
const helper = config.credHelpers?.[server] || config.credsStore;
|
||||||
|
if (!helper || !/^[A-Za-z0-9._-]+$/.test(helper)) throw new Error("Use docker login with an OS credential store before publishing.");
|
||||||
|
const auth = JSON.parse(await run(`docker-credential-${helper}`, ["get"], { input: server + "\n", quiet: true }));
|
||||||
|
if (!auth.Username || !auth.Secret) throw new Error("Docker Hub login is unavailable.");
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
export function dockerHub(auth) {
|
||||||
|
async function token(repository, anonymous) {
|
||||||
|
const url = new URL("https://auth.docker.io/token");
|
||||||
|
url.searchParams.set("service", "registry.docker.io");
|
||||||
|
url.searchParams.set("scope", `repository:${repository}:pull`);
|
||||||
|
const response = await boundedFetch(url, { headers: anonymous ? {} : { Authorization: `Basic ${Buffer.from(`${auth.Username}:${auth.Secret}`).toString("base64")}` } });
|
||||||
|
return (await jsonResponse(response, "Registry authentication")).value.token;
|
||||||
|
}
|
||||||
|
async function registryJSON(repository, route, anonymous, allowMissing = false) {
|
||||||
|
const bearer = await token(repository, anonymous);
|
||||||
|
let response = await boundedFetch(`https://registry-1.docker.io/v2/${repository}/${route}`, { redirect: "manual", headers: { Accept: accept, Authorization: `Bearer ${bearer}` } });
|
||||||
|
if ([302, 307].includes(response.status) && route.startsWith("blobs/")) {
|
||||||
|
const target = new URL(response.headers.get("location"));
|
||||||
|
if (target.protocol !== "https:" || target.username || target.password) throw new Error("Invalid registry blob redirect.");
|
||||||
|
// Signed blob URLs are fetched without forwarding registry credentials.
|
||||||
|
response = await boundedFetch(target);
|
||||||
|
}
|
||||||
|
if (allowMissing && response.status === 404) return null;
|
||||||
|
const { bytes, value } = await jsonResponse(response, "Registry read");
|
||||||
|
const digest = `sha256:${sha256(bytes)}`;
|
||||||
|
const advertised = response.headers.get("docker-content-digest");
|
||||||
|
if (advertised && advertised !== digest) throw new Error("Registry content digest mismatch.");
|
||||||
|
return { value, digest };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
async ensurePublic(namespace, name) {
|
||||||
|
const response = await boundedFetch("https://hub.docker.com/v2/auth/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ identifier: auth.Username, secret: auth.Secret }) });
|
||||||
|
const bearer = (await jsonResponse(response, "Docker Hub authentication")).value.access_token;
|
||||||
|
const headers = { Authorization: `Bearer ${bearer}`, "Content-Type": "application/json" };
|
||||||
|
const path = `https://hub.docker.com/v2/namespaces/${namespace}/repositories`;
|
||||||
|
let existing = await boundedFetch(`${path}/${name}`, { headers });
|
||||||
|
if (existing.status === 404) {
|
||||||
|
existing = await boundedFetch(path, { method: "POST", headers, body: JSON.stringify({ namespace, name, registry: "docker.io", is_private: false, description: `ThothII ${name.endsWith("core") ? "core with embedded Pi" : "standalone frontend"}` }) });
|
||||||
|
}
|
||||||
|
const data = (await jsonResponse(existing, "Public repository preparation")).value;
|
||||||
|
if (data.is_private !== false) throw new Error("Selected Docker Hub repository is private; make this release repository public before retrying.");
|
||||||
|
},
|
||||||
|
async inspect(repository, reference, platform, { anonymous = false, allowMissing = false } = {}) {
|
||||||
|
let image = await registryJSON(repository, `manifests/${reference}`, anonymous, allowMissing);
|
||||||
|
if (!image) return null;
|
||||||
|
if (reference.startsWith("sha256:") && image.digest !== reference) throw new Error("Requested image digest does not match registry content.");
|
||||||
|
if (image.value.manifests) {
|
||||||
|
const match = image.value.manifests.find((entry) => `${entry.platform?.os}/${entry.platform?.architecture}` === platform);
|
||||||
|
if (!match || !/^sha256:[a-f0-9]{64}$/.test(match.digest)) throw new Error("Image does not contain the requested platform.");
|
||||||
|
image = await registryJSON(repository, `manifests/${match.digest}`, anonymous);
|
||||||
|
if (image.digest !== match.digest) throw new Error("Image index digest mismatch.");
|
||||||
|
}
|
||||||
|
if (reference.startsWith("sha256:") && !image.value.config) throw new Error("Image metadata is incomplete.");
|
||||||
|
const configDigest = image.value.config?.digest;
|
||||||
|
if (!/^sha256:[a-f0-9]{64}$/.test(configDigest ?? "")) throw new Error("Image configuration digest is invalid.");
|
||||||
|
const config = await registryJSON(repository, `blobs/${configDigest}`, anonymous);
|
||||||
|
if (config.digest !== configDigest || `${config.value.os}/${config.value.architecture}` !== platform) throw new Error("Image configuration or platform mismatch.");
|
||||||
|
return { reference: `docker.io/${repository}@${image.digest}`, labels: config.value.config?.Labels ?? {} };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { test } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { dockerHub } from "./release-registry.mjs";
|
||||||
|
import { sha256 } from "./release-bundle.mjs";
|
||||||
|
|
||||||
|
test("registry verifies pinned config/platform and does not forward auth to blob storage", async () => {
|
||||||
|
const original = globalThis.fetch;
|
||||||
|
const config = JSON.stringify({ os: "linux", architecture: "amd64", config: { Labels: { "org.opencontainers.image.revision": "b".repeat(40) } } });
|
||||||
|
const configDigest = "sha256:" + sha256(config);
|
||||||
|
const manifest = JSON.stringify({ schemaVersion: 2, config: { digest: configDigest } });
|
||||||
|
const imageDigest = "sha256:" + sha256(manifest);
|
||||||
|
const auth = [];
|
||||||
|
globalThis.fetch = async (target, options) => {
|
||||||
|
const url = new URL(target);
|
||||||
|
if (url.hostname === "auth.docker.io") return new Response(JSON.stringify({ token: "registry-token" }));
|
||||||
|
if (url.hostname === "blob.example.test") { auth.push(options.headers?.Authorization); return new Response(config); }
|
||||||
|
if (url.pathname.includes("/blobs/")) return new Response(null, { status: 307, headers: { location: "https://blob.example.test/config" } });
|
||||||
|
return new Response(manifest, { headers: { "docker-content-digest": imageDigest } });
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const registry = dockerHub({ Username: "publisher", Secret: "PRIVATE_TOKEN" });
|
||||||
|
const image = await registry.inspect("example/core", imageDigest, "linux/amd64", { anonymous: true });
|
||||||
|
assert.equal(image.reference, `docker.io/example/core@${imageDigest}`);
|
||||||
|
assert.deepEqual(auth, [undefined]);
|
||||||
|
await assert.rejects(registry.inspect("example/core", imageDigest, "linux/arm64"), /platform mismatch/);
|
||||||
|
await assert.rejects(registry.inspect("example/core", "sha256:" + "0".repeat(64), "linux/amd64"), /Requested image digest/);
|
||||||
|
} finally { globalThis.fetch = original; }
|
||||||
|
});
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { test } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import { join, resolve } from 'node:path';
|
||||||
|
import { prepareBundle } from './release-bundle.mjs';
|
||||||
|
import { buildSourceImages, sourceOptions } from './prepare-source-installation.mjs';
|
||||||
|
|
||||||
|
test('source builds load local images from the isolated checkout without publication or secrets', async () => {
|
||||||
|
const output = mkdtempSync(join(tmpdir(), 'source-build-'));
|
||||||
|
const calls = [];
|
||||||
|
const revision = 'c'.repeat(40), version = '1.0.0-source', platform = 'linux/amd64';
|
||||||
|
const run = async (command, args, options) => {
|
||||||
|
calls.push({ command, args, options });
|
||||||
|
if (args[0] === 'buildx') {
|
||||||
|
assert.equal(options.cwd, '/isolated/committed-source');
|
||||||
|
assert.ok(args.includes('--load'));
|
||||||
|
assert.ok(!args.includes('--push'));
|
||||||
|
assert.ok(!args.includes('--secret'));
|
||||||
|
assert.deepEqual(args.filter((_, index) => args[index - 1] === '--build-arg'), [`IMAGE_VERSION=${version}`]);
|
||||||
|
// Containerd may expose the manifest as local Id while Buildx writes its config digest.
|
||||||
|
writeFileSync(args[args.indexOf('--iidfile') + 1], `sha256:${'b'.repeat(64)}`);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return JSON.stringify({ Id: `sha256:${'a'.repeat(64)}`, Os: 'linux', Architecture: 'amd64', Config: { Labels: { 'org.opencontainers.image.revision': revision, 'org.opencontainers.image.version': version } } });
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
assert.deepEqual(await buildSourceImages({ run, source: '/isolated/committed-source', output, revision, version, platform }), { core: `sha256:${'a'.repeat(64)}`, frontend: `sha256:${'a'.repeat(64)}` });
|
||||||
|
assert.equal(calls.length, 4);
|
||||||
|
assert.throws(() => sourceOptions(['--revision', 'HEAD']), /explicit/);
|
||||||
|
} finally { rmSync(output, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test('source bundles identify their mode and use immutable local application images', () => {
|
||||||
|
const output = mkdtempSync(join(tmpdir(), 'source-bundle-'));
|
||||||
|
const images = Object.fromEntries(['core', 'frontend', 'catalog', 'qdrant', 'embedding'].map(role => [role,
|
||||||
|
['core', 'frontend'].includes(role) ? `sha256:${'a'.repeat(64)}` : `docker.io/example/${role}@sha256:${'b'.repeat(64)}`]));
|
||||||
|
try {
|
||||||
|
const manifest = prepareBundle({ source: resolve(import.meta.dirname, '../..'), destination: output,
|
||||||
|
platform: 'linux/arm64', version: '0.1.0-source', revision: 'c'.repeat(40), images, distribution: 'source' });
|
||||||
|
assert.equal(manifest.distribution, 'source');
|
||||||
|
assert.equal(manifest.images.core['linux/arm64'], images.core);
|
||||||
|
assert.doesNotMatch(readFileSync(join(output, 'compose.yaml'), 'utf8'), /build:/);
|
||||||
|
assert.throws(() => prepareBundle({ source: resolve(import.meta.dirname, '../..'), destination: output,
|
||||||
|
platform: 'linux/arm64', version: '0.1.0-source', revision: 'c'.repeat(40), images }), /immutable/);
|
||||||
|
} finally { rmSync(output, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
@@ -48,6 +48,8 @@ import { createCatalogRepository } from "./catalog/repository.js";
|
|||||||
import type { CatalogRepository } from "./catalog/types.js";
|
import type { CatalogRepository } from "./catalog/types.js";
|
||||||
import { CatalogService } from "./catalog/service.js";
|
import { CatalogService } from "./catalog/service.js";
|
||||||
import { catalogDatabaseRoutes } from "./routes/catalog-databases.js";
|
import { catalogDatabaseRoutes } from "./routes/catalog-databases.js";
|
||||||
|
import { installationRoutes } from "./routes/installation.js";
|
||||||
|
import { InstallationBindings } from "./catalog/installation-bindings.js";
|
||||||
import { CatalogOperationCoordinator } from "./catalog/operation-coordinator.js";
|
import { CatalogOperationCoordinator } from "./catalog/operation-coordinator.js";
|
||||||
import { ConcreteCatalogPostgresAccess, type CatalogPostgresAccess } from "./catalog/postgres-access.js";
|
import { ConcreteCatalogPostgresAccess, type CatalogPostgresAccess } from "./catalog/postgres-access.js";
|
||||||
import { CatalogTableService } from "./catalog/table-service.js";
|
import { CatalogTableService } from "./catalog/table-service.js";
|
||||||
@@ -530,6 +532,8 @@ export function buildApp(config: AppConfig, deps?: BuildAppDeps): FastifyInstanc
|
|||||||
}).readLatestJob(),
|
}).readLatestJob(),
|
||||||
});
|
});
|
||||||
catalogDatabaseRoutes(app, { repository: catalogRepository, service: catalogService, operations: catalogOperationCoordinator });
|
catalogDatabaseRoutes(app, { repository: catalogRepository, service: catalogService, operations: catalogOperationCoordinator });
|
||||||
|
installationRoutes(app, new InstallationBindings(catalogRepository, catalogService, workspaceRegistry,
|
||||||
|
workspaceSecretStore, catalogOperationCoordinator, config.workspaceRegistry.installationId), workspaceRegistry);
|
||||||
catalogTableRoutes(app, {
|
catalogTableRoutes(app, {
|
||||||
repository: catalogRepository,
|
repository: catalogRepository,
|
||||||
service: catalogTableService,
|
service: catalogTableService,
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { readFileSync, lstatSync } from "node:fs";
|
||||||
|
import { parseAllDocuments } from "yaml";
|
||||||
|
import { decode, DocumentError, runWorkspaceDocuments } from "../workspaces/documents.js";
|
||||||
|
import { validateDatabaseBootstrap } from "./bootstrap-documents.js";
|
||||||
|
|
||||||
|
/** Internal sibling protocol: only references cross back to Go, never secret contents. */
|
||||||
|
export function runBootstrapValidation(args: string[]): { status: number; output: string } {
|
||||||
|
try {
|
||||||
|
if (args.length !== 5 || args[0] !== "--directory" || args[2] !== "--bootstrap" || args[4] !== "--json") throw new Error("usage");
|
||||||
|
const checked = runWorkspaceDocuments(["validate", "--directory", args[1], "--json"]);
|
||||||
|
if (checked.status !== 0) return checked;
|
||||||
|
const info = lstatSync(args[3]);
|
||||||
|
if (!info.isFile() || info.isSymbolicLink() || info.size > 1024 * 1024) throw new Error("file");
|
||||||
|
const validated = decode(readFileSync(args[3], "utf8"), "database-bootstrap.yaml", (source) =>
|
||||||
|
validateDatabaseBootstrap(parseAllDocuments(source)[0].toJSON(), args[1]), "database bootstrap schema v1 and the Catalog binding contract");
|
||||||
|
return { status: 0, output: JSON.stringify({ schema_version: 1, ok: true, secret_files: validated.secretFiles, warnings: validated.warnings, issues: [] }) };
|
||||||
|
} catch (error) {
|
||||||
|
const issue = error instanceof DocumentError ? error.issue : { document: "database-bootstrap.yaml", field: "$", code: "bootstrap_invalid", correction: "Supply one complete Catalog database configuration per workspace in a readable local bootstrap document." };
|
||||||
|
return { status: 1, output: JSON.stringify({ schema_version: 1, ok: false, issues: [issue] }) };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { databaseConfigurationSchema } from "./configuration-schema.js";
|
||||||
|
import { parseWorkspaceCatalogYaml } from "../workspaces/catalog.js";
|
||||||
|
import { parseWorkspaceYaml } from "../workspaces/schema.js";
|
||||||
|
import { discoverWorkspaceSecretRequirements } from "../workspaces/secret-requirements.js";
|
||||||
|
|
||||||
|
const reference = z.string().min(1).max(4096);
|
||||||
|
const database = databaseConfigurationSchema.extend({
|
||||||
|
secretFiles: z.object({ password: reference.optional(), apiKey: reference.optional(), sshPrivateKey: reference.optional(), sshPrivateKeyPassphrase: reference.optional(), sshKnownHosts: reference.optional(), tlsCa: reference.optional() }).strict(),
|
||||||
|
evidenceSecretFiles: z.object({ "evidence.signed_urls": reference.optional(), "evidence.access_key": reference.optional(), "evidence.secret_key": reference.optional(), "evidence.session_token": reference.optional() }).strict().optional(),
|
||||||
|
});
|
||||||
|
const bootstrap = z.object({ schemaVersion: z.literal(1),
|
||||||
|
authentication: z.object({ username: z.string().min(1).max(128), passwordFile: reference }).strict().optional(),
|
||||||
|
databases: z.array(database).min(1).max(1000) }).strict();
|
||||||
|
|
||||||
|
export const parseDatabaseBootstrap = (value: unknown) => bootstrap.parse(value);
|
||||||
|
|
||||||
|
export interface BootstrapReference { field: string; path: string }
|
||||||
|
|
||||||
|
/** Offline bootstrap boundary: runtime Catalog owns the resulting bindings after import. */
|
||||||
|
export function validateDatabaseBootstrap(value: unknown, workspaceRoot: string): { secretFiles: BootstrapReference[]; warnings: string[] } {
|
||||||
|
const document = bootstrap.parse(value);
|
||||||
|
const catalog = parseWorkspaceCatalogYaml(readFileSync(join(workspaceRoot, "thoth-workspaces.yaml"), "utf8"));
|
||||||
|
const expected = new Set(catalog.workspaces.map((entry) => entry.id));
|
||||||
|
const seen = new Set<string>();
|
||||||
|
const secretFiles: BootstrapReference[] = [];
|
||||||
|
if (document.authentication) secretFiles.push({ field: "authentication.passwordFile", path: document.authentication.passwordFile });
|
||||||
|
const warnings: string[] = [];
|
||||||
|
const issue = (path: (string | number)[], message: string): never => { throw new z.ZodError([{ code: "custom", path, message }]); };
|
||||||
|
document.databases.forEach((entry, index) => {
|
||||||
|
if (!expected.has(entry.workspaceId) || seen.has(entry.workspaceId)) issue(["databases", index, "workspaceId"], "Declare each catalog workspace exactly once.");
|
||||||
|
seen.add(entry.workspaceId);
|
||||||
|
const required = entry.binding.transport === "rest_api"
|
||||||
|
? entry.binding.restAuth === "none" ? [] : ["apiKey"] as const
|
||||||
|
: entry.binding.transport === "ssh_tunnel" ? ["password", "sshPrivateKey", "sshKnownHosts"] as const : ["password"] as const;
|
||||||
|
for (const name of required) {
|
||||||
|
if (!entry.secretFiles[name]) issue(["databases", index, "secretFiles", name], "Supply a protected file reference for this transport.");
|
||||||
|
}
|
||||||
|
if (entry.binding.transport === "ssh_tunnel") warnings.push(`databases.${index}:ssh_tunnel supports Catalog diagnostics, not NL-to-SQL sessions; choose direct or REST for practice.`);
|
||||||
|
for (const [name, path] of Object.entries(entry.secretFiles)) secretFiles.push({ field: `databases.${index}.secretFiles.${name}`, path });
|
||||||
|
const workspace = parseWorkspaceYaml(readFileSync(join(workspaceRoot, entry.workspaceId, "workspace.yaml"), "utf8"));
|
||||||
|
const requirements = discoverWorkspaceSecretRequirements(workspace, {});
|
||||||
|
for (const requirement of requirements.filter((item) => item.connector === "evidence" && item.required)) {
|
||||||
|
if (!(entry.evidenceSecretFiles as Record<string, string> | undefined)?.[requirement.id]) issue(["databases", index, "evidenceSecretFiles"], "Supply the configured Evidence authentication file references.");
|
||||||
|
}
|
||||||
|
for (const [name, path] of Object.entries(entry.evidenceSecretFiles ?? {})) secretFiles.push({ field: `databases.${index}.evidenceSecretFiles.${name}`, path });
|
||||||
|
});
|
||||||
|
if (seen.size !== expected.size) issue(["databases"], "Add a database binding for every catalog workspace.");
|
||||||
|
return { secretFiles, warnings };
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
|
||||||
|
import { parseWorkspaceYaml } from "../workspaces/schema.js";
|
||||||
|
import { evidencePolicy } from "../workspaces/evidence/preprocessing.js";
|
||||||
|
import type { parseDatabaseBootstrap } from "./bootstrap-documents.js";
|
||||||
|
import { probePublicEvidenceUrl, publicEvidenceAgent } from "./evidence-probe-http.js";
|
||||||
|
|
||||||
|
type Entry = ReturnType<typeof parseDatabaseBootstrap>["databases"][number];
|
||||||
|
|
||||||
|
/** Read-only availability probes; domain correctness and materialization remain runtime gates. */
|
||||||
|
export async function probeEvidence(entry: Entry, root: string): Promise<void> {
|
||||||
|
const evidence = parseWorkspaceYaml(readFileSync(join(root, entry.workspaceId, "workspace.yaml"), "utf8")).evidence;
|
||||||
|
if (!evidence || evidence.source.type === "filesystem") return;
|
||||||
|
if (evidencePolicy(evidence)) throw new Error("Evidence egress policy refused");
|
||||||
|
const secret = (name: keyof NonNullable<Entry["evidenceSecretFiles"]>) => {
|
||||||
|
const path = entry.evidenceSecretFiles?.[name];
|
||||||
|
if (!path) throw new Error("Evidence credential missing");
|
||||||
|
return readFileSync(path, "utf8").trim();
|
||||||
|
};
|
||||||
|
const source = evidence.source;
|
||||||
|
if (source.type === "http") {
|
||||||
|
const urls: unknown = source.authentication === "signed_urls_file"
|
||||||
|
? JSON.parse(secret("evidence.signed_urls")) : source.uris;
|
||||||
|
if (!Array.isArray(urls) || urls.length !== source.uris.length || urls.length > 1000) throw new Error("Invalid signed URLs");
|
||||||
|
for (const [index, value] of urls.entries()) {
|
||||||
|
if (typeof value !== "string") throw new Error("Invalid signed URL");
|
||||||
|
const url = new URL(value);
|
||||||
|
const provenance = new URL(source.uris[index]);
|
||||||
|
// Signed queries may authorize the same identity, never a different host/path.
|
||||||
|
if (url.origin !== provenance.origin || url.pathname !== provenance.pathname || url.username || url.password || url.hash) throw new Error("Invalid signed URL identity");
|
||||||
|
await probePublicEvidenceUrl(url);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The shared runtime policy currently permits trusted AWS endpoints with explicit file credentials.
|
||||||
|
const location = new URL(source.uri);
|
||||||
|
const client = new S3Client({
|
||||||
|
region: source.region ?? "us-east-1", maxAttempts: 1,
|
||||||
|
requestHandler: { httpsAgent: publicEvidenceAgent(), connectionTimeout: 5_000, requestTimeout: 5_000 },
|
||||||
|
credentials: { accessKeyId: secret("evidence.access_key"), secretAccessKey: secret("evidence.secret_key"),
|
||||||
|
...(entry.evidenceSecretFiles?.["evidence.session_token"] ? { sessionToken: secret("evidence.session_token") } : {}) },
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await client.send(new ListObjectsV2Command({ Bucket: location.hostname, Prefix: decodeURIComponent(location.pathname.slice(1)), MaxKeys: 1 }), { abortSignal: AbortSignal.timeout(5_000) });
|
||||||
|
} finally { client.destroy(); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { parse } from "yaml";
|
||||||
|
import { parseDatabaseBootstrap } from "./bootstrap-documents.js";
|
||||||
|
import { runBootstrapValidation } from "./bootstrap-cli.js";
|
||||||
|
import { createConcreteDiagnosticAdapters, type DiagnosticAdapters } from "../workspaces/diagnostics.js";
|
||||||
|
import { probeEvidence } from "./bootstrap-evidence-probes.js";
|
||||||
|
|
||||||
|
interface ProbeCheck { id: string; outcome: "passed" | "error"; field: string; action: string }
|
||||||
|
|
||||||
|
/** Uses the same read-only, authenticated connector diagnostics as the Catalog. */
|
||||||
|
export async function probeBootstrapDependencies(value: unknown, adapters: DiagnosticAdapters = createConcreteDiagnosticAdapters(), workspaceRoot?: string) {
|
||||||
|
const document = parseDatabaseBootstrap(value);
|
||||||
|
const checks: ProbeCheck[] = [];
|
||||||
|
for (const [index, entry] of document.databases.entries()) {
|
||||||
|
let outcome: ProbeCheck["outcome"] = "passed";
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timer = setTimeout(() => controller.abort(), 5_000);
|
||||||
|
try {
|
||||||
|
if (entry.binding.transport === "ssh_tunnel") throw new Error("session transport unavailable");
|
||||||
|
await adapters.probeConnector({
|
||||||
|
role: "dwh", transport: entry.binding.transport,
|
||||||
|
host: entry.binding.host, port: entry.binding.port, user: entry.binding.username,
|
||||||
|
baseUrl: entry.binding.baseUrl,
|
||||||
|
credentialFile: entry.binding.transport === "rest_api" ? entry.secretFiles.apiKey : entry.secretFiles.password,
|
||||||
|
tlsCaFile: entry.secretFiles.tlsCa, tlsServername: entry.binding.tlsServername,
|
||||||
|
resource: { database: entry.databaseName, schema: entry.schema },
|
||||||
|
timeoutMs: 5_000, signal: controller.signal,
|
||||||
|
diagnostic: { method: "GET", path: entry.binding.restPath ?? "/health", auth: entry.binding.restAuth ?? "bearer" },
|
||||||
|
});
|
||||||
|
} catch { outcome = "error"; } finally { clearTimeout(timer); }
|
||||||
|
checks.push({ id: `database-${index}`, outcome, field: `database-bootstrap.databases.${index}`,
|
||||||
|
action: entry.binding.transport === "ssh_tunnel"
|
||||||
|
? "Choose postgres_direct or rest_api for NL-to-SQL practice; SSH diagnostics alone cannot establish session readiness."
|
||||||
|
: "Require an authenticated read-only connection and access to the configured database/schema; correct endpoint, permissions or protected credentials." });
|
||||||
|
if (workspaceRoot) {
|
||||||
|
let evidenceOutcome: ProbeCheck["outcome"] = "passed";
|
||||||
|
try { await probeEvidence(entry, workspaceRoot); } catch { evidenceOutcome = "error"; }
|
||||||
|
checks.push({ id: `evidence-${index}`, outcome: evidenceOutcome, field: `workspaces.${index}.evidence`, action: "Require readable local Evidence or authenticated bounded HTTP/S3 access under the canonical egress policy; domain meaning is verified during practice." });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { schema_version: 1, ok: checks.every((check) => check.outcome === "passed"), checks };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function runBootstrapProbes(args: string[]) {
|
||||||
|
const validation = runBootstrapValidation(args);
|
||||||
|
if (validation.status !== 0) return validation;
|
||||||
|
try {
|
||||||
|
const report = await probeBootstrapDependencies(parse(readFileSync(args[3], "utf8")), undefined, args[1]);
|
||||||
|
return { status: report.ok ? 0 : 1, output: JSON.stringify(report) };
|
||||||
|
} catch {
|
||||||
|
return { status: 1, output: JSON.stringify({ schema_version: 1, ok: false, checks: [{ id: "database-probes", outcome: "error", field: "database-bootstrap", action: "Revalidate prepared documents and protected credential references." }] }) };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
import { parseCredentialFreeHttpUrl } from "../auth/url-policy.js";
|
||||||
|
import { DATABASE_TRANSPORTS } from "./types.js";
|
||||||
|
|
||||||
|
const workspaceIdSchema = z.string().regex(/^[a-z][a-z0-9-]{2,62}$/);
|
||||||
|
const identifier = z.string().trim().min(1).max(128).regex(/^[A-Za-z_][A-Za-z0-9_$-]*$/);
|
||||||
|
const nonEmpty = z.string().trim().min(1).max(512);
|
||||||
|
const port = z.number().int().min(1).max(65_535);
|
||||||
|
const optionalText = nonEmpty.optional();
|
||||||
|
const sshHost = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9_.:\[\]-]+$/).optional();
|
||||||
|
const sshUsername = z.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/).optional();
|
||||||
|
const bindingSchema = z.object({
|
||||||
|
transport: z.enum(DATABASE_TRANSPORTS),
|
||||||
|
host: optionalText,
|
||||||
|
port: port.optional(),
|
||||||
|
username: optionalText,
|
||||||
|
baseUrl: z.string().max(2048)
|
||||||
|
.refine((value) => parseCredentialFreeHttpUrl(value) !== undefined)
|
||||||
|
.optional(),
|
||||||
|
restPath: z.string().regex(/^\/(?!\/)[^?#\\\u0000-\u001f]*$/).max(512).optional(),
|
||||||
|
restAuth: z.enum(["none", "bearer", "x-api-key"]).optional(),
|
||||||
|
tlsServername: optionalText,
|
||||||
|
sshHost,
|
||||||
|
sshPort: port.optional(),
|
||||||
|
sshUsername,
|
||||||
|
sshTargetHost: sshHost,
|
||||||
|
sshTargetPort: port.optional(),
|
||||||
|
}).strict().superRefine((binding, context) => {
|
||||||
|
const required = binding.transport === "postgres_direct"
|
||||||
|
? ["host", "port", "username"] as const
|
||||||
|
: binding.transport === "rest_api"
|
||||||
|
? ["baseUrl", "restPath", "restAuth"] as const
|
||||||
|
: ["username", "sshHost", "sshPort", "sshUsername", "sshTargetHost", "sshTargetPort"] as const;
|
||||||
|
for (const field of required) {
|
||||||
|
if (binding[field] === undefined) context.addIssue({ code: "custom", path: [field], message: "Required" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
export const databaseConfigurationSchema = z.object({
|
||||||
|
workspaceId: workspaceIdSchema,
|
||||||
|
engine: z.literal("postgres"),
|
||||||
|
databaseName: identifier,
|
||||||
|
schema: identifier,
|
||||||
|
binding: bindingSchema,
|
||||||
|
}).strict();
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { lookup } from "node:dns/promises";
|
||||||
|
import { request as httpRequest } from "node:http";
|
||||||
|
import { request as httpsRequest, Agent } from "node:https";
|
||||||
|
import type { LookupFunction } from "node:net";
|
||||||
|
import ipaddr from "ipaddr.js";
|
||||||
|
|
||||||
|
const refused = () => new Error("Evidence network policy refused");
|
||||||
|
function normalizedPublicAddress(value: string): string {
|
||||||
|
const address = ipaddr.process(value);
|
||||||
|
if (address.range() !== "unicast") throw refused();
|
||||||
|
return address.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reject the entire DNS answer set, then pin the connection to that verified set. */
|
||||||
|
export async function resolvePublicEvidenceHost(hostname: string) {
|
||||||
|
const values = await lookup(hostname.replace(/^\[|\]$/g, ""), { all: true });
|
||||||
|
if (!values.length) throw refused();
|
||||||
|
values.forEach((value) => normalizedPublicAddress(value.address));
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
const publicLookup: LookupFunction = (hostname, options, callback) => {
|
||||||
|
void resolvePublicEvidenceHost(hostname).then((values) => {
|
||||||
|
if (options.all) callback(null, values);
|
||||||
|
else callback(null, values[0].address, values[0].family);
|
||||||
|
}, () => callback(refused(), "", 0));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Node's direct agent does not inherit HTTP proxy environment or ambient credentials.
|
||||||
|
export const publicEvidenceAgent = () => new Agent({ lookup: publicLookup });
|
||||||
|
|
||||||
|
export async function probePublicEvidenceUrl(url: URL): Promise<void> {
|
||||||
|
if (!['http:', 'https:'].includes(url.protocol)) throw refused();
|
||||||
|
const signal = AbortSignal.timeout(5_000);
|
||||||
|
const values = await Promise.race([
|
||||||
|
resolvePublicEvidenceHost(url.hostname),
|
||||||
|
new Promise<never>((_, reject) => signal.addEventListener("abort", () => reject(refused()), { once: true })),
|
||||||
|
]);
|
||||||
|
signal.throwIfAborted();
|
||||||
|
const allowed = new Set(values.map((value) => normalizedPublicAddress(value.address)));
|
||||||
|
const pinned: LookupFunction = (_hostname, options, callback) => {
|
||||||
|
if (options.all) callback(null, values);
|
||||||
|
else callback(null, values[0].address, values[0].family);
|
||||||
|
};
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
const request = (url.protocol === "https:" ? httpsRequest : httpRequest)(url, {
|
||||||
|
method: "GET", lookup: pinned, signal, agent: false,
|
||||||
|
}, (response) => {
|
||||||
|
try {
|
||||||
|
const peer = response.socket.remoteAddress;
|
||||||
|
if (!peer || !allowed.has(normalizedPublicAddress(peer)) || !response.statusCode || response.statusCode < 200 || response.statusCode >= 300) throw refused();
|
||||||
|
resolve();
|
||||||
|
} catch { reject(refused()); } finally { response.destroy(); }
|
||||||
|
});
|
||||||
|
request.on("error", () => reject(refused()));
|
||||||
|
request.end();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { isDeepStrictEqual } from "node:util";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { databaseConfigurationSchema } from "./configuration-schema.js";
|
||||||
|
import { CATALOG_SECRET_IDS } from "./secrets.js";
|
||||||
|
import type { CatalogRepository } from "./types.js";
|
||||||
|
import type { CatalogService } from "./service.js";
|
||||||
|
import type { CatalogOperationCoordinator } from "./operation-coordinator.js";
|
||||||
|
import type { WorkspaceRegistry } from "../workspaces/registry.js";
|
||||||
|
import type { WorkspaceSecretStore } from "../workspaces/secret-store.js";
|
||||||
|
import { discoverWorkspaceSecretRequirements } from "../workspaces/secret-requirements.js";
|
||||||
|
|
||||||
|
const secret = z.string().min(1).refine(value => Buffer.byteLength(value, "utf8") <= 65536);
|
||||||
|
export const installationBindingSchema = z.object({
|
||||||
|
schemaVersion: z.literal(1), revision: z.string().regex(/^[a-f0-9]{40}$/),
|
||||||
|
configuration: databaseConfigurationSchema,
|
||||||
|
secrets: z.object({ password: secret.optional(), apiKey: secret.optional(), sshPrivateKey: secret.optional(),
|
||||||
|
sshPrivateKeyPassphrase: secret.optional(), sshKnownHosts: secret.optional(), tlsCa: secret.optional() }).strict(),
|
||||||
|
evidenceSecrets: z.object({ "evidence.signed_urls": secret.optional(), "evidence.access_key": secret.optional(),
|
||||||
|
"evidence.secret_key": secret.optional(), "evidence.session_token": secret.optional() }).strict(),
|
||||||
|
}).strict();
|
||||||
|
|
||||||
|
export class InstallationReconciliationRequired extends Error {}
|
||||||
|
const conflict = () => { throw new InstallationReconciliationRequired("Reconcile the prepared documents with current administrative state."); };
|
||||||
|
|
||||||
|
/** Only called behind the ordinary authenticated administration permission boundary. */
|
||||||
|
export class InstallationBindings {
|
||||||
|
constructor(private readonly repository: CatalogRepository, private readonly catalog: CatalogService,
|
||||||
|
private readonly registry: WorkspaceRegistry, private readonly secrets: WorkspaceSecretStore,
|
||||||
|
private readonly operations: CatalogOperationCoordinator, private readonly installationId: string) {}
|
||||||
|
|
||||||
|
async apply(raw: unknown) {
|
||||||
|
const request = installationBindingSchema.parse(raw);
|
||||||
|
const workspaceId = request.configuration.workspaceId;
|
||||||
|
const { workspace, revision } = await this.registry.read(workspaceId);
|
||||||
|
if (revision.commit !== request.revision) return conflict();
|
||||||
|
const input = await this.catalog.normalizeInput(request.configuration);
|
||||||
|
const required = input.binding.transport === "rest_api" ? (input.binding.restAuth === "none" ? [] : ["apiKey"])
|
||||||
|
: input.binding.transport === "ssh_tunnel" ? ["password", "sshPrivateKey", "sshKnownHosts"] : ["password"];
|
||||||
|
if (required.some(name => !request.secrets[name as keyof typeof request.secrets])) return conflict();
|
||||||
|
const evidenceRequirements = discoverWorkspaceSecretRequirements(workspace, {}).filter(item => item.connector === "evidence" && item.required);
|
||||||
|
if (evidenceRequirements.some(item => !(request.evidenceSecrets as Record<string, string>)[item.id])) return conflict();
|
||||||
|
const values: Record<string, string> = { ...request.evidenceSecrets };
|
||||||
|
for (const [name, value] of Object.entries(request.secrets)) values[CATALOG_SECRET_IDS[name as keyof typeof CATALOG_SECRET_IDS]] = value;
|
||||||
|
// Stable installation-local identity is persisted atomically with the initial binding.
|
||||||
|
// A crash before any host journal update is recoverable without adopting a manually created row.
|
||||||
|
const hex = createHash("sha256").update(`thothii-installation-binding-v1\0${this.installationId}\0${workspaceId}`).digest("hex");
|
||||||
|
const id = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
||||||
|
const applied = await this.operations.run(id, async () => {
|
||||||
|
let current = await this.repository.getByWorkspace(workspaceId);
|
||||||
|
let changed = false;
|
||||||
|
if (!current) { current = await this.repository.create(input, id); changed = true; }
|
||||||
|
if (current.id !== id || !isDeepStrictEqual(input, {
|
||||||
|
workspaceId: current.workspaceId, engine: current.engine, databaseName: current.databaseName,
|
||||||
|
schema: current.schema, binding: Object.fromEntries(Object.entries(current.binding).filter(([, value]) => value !== undefined)),
|
||||||
|
})) return conflict();
|
||||||
|
const configured = this.secrets.configured(workspaceId).filter(name => name.startsWith("catalog.") || name.startsWith("evidence."));
|
||||||
|
if (configured.some(name => values[name] === undefined || !this.secrets.matches(workspaceId, name, values[name]))) return conflict();
|
||||||
|
const missing = Object.fromEntries(Object.entries(values).filter(([name]) => !configured.includes(name)));
|
||||||
|
if (Object.keys(missing).length) {
|
||||||
|
if (current.version !== 1) return conflict();
|
||||||
|
// Synchronous atomic vault update cannot interleave with another mutation in this core.
|
||||||
|
this.secrets.putMany(workspaceId, missing); changed = true;
|
||||||
|
}
|
||||||
|
if (current.version === 1) {
|
||||||
|
const touched = await this.repository.touch(id, current.version);
|
||||||
|
if (!touched) return conflict();
|
||||||
|
current = touched; changed = true;
|
||||||
|
}
|
||||||
|
return { current, changed };
|
||||||
|
});
|
||||||
|
const tested = await this.catalog.test(applied.current);
|
||||||
|
if (!tested || tested.version !== applied.current.version || (await this.registry.read(workspaceId)).revision.commit !== request.revision) return conflict();
|
||||||
|
return { schemaVersion: 1, workspaceId, databaseId: tested.id, version: tested.version,
|
||||||
|
status: applied.changed ? "applied" : "unchanged", connectionStatus: tested.connectionStatus };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,7 @@ function clone(value: WorkspaceDatabase): WorkspaceDatabase {
|
|||||||
/** Deterministic repository used by route tests and local contract consumers. */
|
/** Deterministic repository used by route tests and local contract consumers. */
|
||||||
export class MemoryCatalogRepository implements CatalogRepository {
|
export class MemoryCatalogRepository implements CatalogRepository {
|
||||||
private readonly records = new Map<string, WorkspaceDatabase>();
|
private readonly records = new Map<string, WorkspaceDatabase>();
|
||||||
|
private readonly installationImports = new Set<string>();
|
||||||
private readonly tables = new Map<string, CatalogTable>();
|
private readonly tables = new Map<string, CatalogTable>();
|
||||||
private readonly columns = new Map<string, CatalogColumn>();
|
private readonly columns = new Map<string, CatalogColumn>();
|
||||||
private readonly relationships = new Map<string, CatalogPhysicalRelationship>();
|
private readonly relationships = new Map<string, CatalogPhysicalRelationship>();
|
||||||
@@ -77,6 +78,7 @@ export class MemoryCatalogRepository implements CatalogRepository {
|
|||||||
async beginPreprocessing(
|
async beginPreprocessing(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
|
runId?: string,
|
||||||
): Promise<CatalogPreprocessingStartResult> {
|
): Promise<CatalogPreprocessingStartResult> {
|
||||||
const database = [...this.records.values()].find((record) => record.workspaceId === workspaceId);
|
const database = [...this.records.values()].find((record) => record.workspaceId === workspaceId);
|
||||||
if (!database) return { kind: "not_found" };
|
if (!database) return { kind: "not_found" };
|
||||||
@@ -95,6 +97,7 @@ export class MemoryCatalogRepository implements CatalogRepository {
|
|||||||
...database,
|
...database,
|
||||||
preprocessingStatus: "running",
|
preprocessingStatus: "running",
|
||||||
preprocessingInputFingerprint: inputFingerprint,
|
preprocessingInputFingerprint: inputFingerprint,
|
||||||
|
preprocessingRunId: runId,
|
||||||
preprocessedMetadataRevision: undefined,
|
preprocessedMetadataRevision: undefined,
|
||||||
preprocessingStartedAt: now,
|
preprocessingStartedAt: now,
|
||||||
preprocessingFinishedAt: undefined,
|
preprocessingFinishedAt: undefined,
|
||||||
@@ -109,12 +112,14 @@ export class MemoryCatalogRepository implements CatalogRepository {
|
|||||||
metadataContentRevision: number,
|
metadataContentRevision: number,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
||||||
|
runId?: string,
|
||||||
): Promise<WorkspaceDatabase | undefined> {
|
): Promise<WorkspaceDatabase | undefined> {
|
||||||
const database = [...this.records.values()].find((record) => record.workspaceId === workspaceId);
|
const database = [...this.records.values()].find((record) => record.workspaceId === workspaceId);
|
||||||
if (!database
|
if (!database
|
||||||
|| database.preprocessingStatus !== "running"
|
|| database.preprocessingStatus !== "running"
|
||||||
|| database.metadataContentRevision !== metadataContentRevision
|
|| database.metadataContentRevision !== metadataContentRevision
|
||||||
|| database.preprocessingInputFingerprint !== inputFingerprint) return undefined;
|
|| database.preprocessingInputFingerprint !== inputFingerprint
|
||||||
|
|| database.preprocessingRunId !== runId) return undefined;
|
||||||
const updated: WorkspaceDatabase = {
|
const updated: WorkspaceDatabase = {
|
||||||
...database,
|
...database,
|
||||||
preprocessingStatus: outcome.status,
|
preprocessingStatus: outcome.status,
|
||||||
@@ -175,13 +180,13 @@ export class MemoryCatalogRepository implements CatalogRepository {
|
|||||||
...relationships.map((relationship) => relationship.updatedAt),
|
...relationships.map((relationship) => relationship.updatedAt),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
async create(input: DatabaseConfigurationInput): Promise<WorkspaceDatabase> {
|
async create(input: DatabaseConfigurationInput, creationId?: string): Promise<WorkspaceDatabase> {
|
||||||
if ([...this.records.values()].some((record) => record.workspaceId === input.workspaceId)) {
|
if ((creationId && this.installationImports.has(input.workspaceId)) || [...this.records.values()].some((record) => record.workspaceId === input.workspaceId)) {
|
||||||
throw new CatalogConflictError("Workspace database already exists");
|
throw new CatalogConflictError("Workspace database already exists");
|
||||||
}
|
}
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
const record: WorkspaceDatabase = {
|
const record: WorkspaceDatabase = {
|
||||||
id: randomUUID(),
|
id: creationId ?? randomUUID(),
|
||||||
...structuredClone(input),
|
...structuredClone(input),
|
||||||
version: 1,
|
version: 1,
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
@@ -191,6 +196,7 @@ export class MemoryCatalogRepository implements CatalogRepository {
|
|||||||
preprocessingStatus: "failed",
|
preprocessingStatus: "failed",
|
||||||
};
|
};
|
||||||
this.records.set(record.id, record);
|
this.records.set(record.id, record);
|
||||||
|
if (creationId) this.installationImports.add(input.workspaceId);
|
||||||
return clone(record);
|
return clone(record);
|
||||||
}
|
}
|
||||||
async update(id: string, expectedVersion: number, input: DatabaseConfigurationInput): Promise<WorkspaceDatabase | undefined> {
|
async update(id: string, expectedVersion: number, input: DatabaseConfigurationInput): Promise<WorkspaceDatabase | undefined> {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import * as canonicalModelIdsMigration from "./migrations/010_canonical_model_id
|
|||||||
import * as localSensitivityAnalysisMigration from "./migrations/011_local_sensitivity_analysis.js";
|
import * as localSensitivityAnalysisMigration from "./migrations/011_local_sensitivity_analysis.js";
|
||||||
import * as sensitivityReasonMigration from "./migrations/012_sensitivity_reason.js";
|
import * as sensitivityReasonMigration from "./migrations/012_sensitivity_reason.js";
|
||||||
import * as catalogPreprocessingStateMigration from "./migrations/013_catalog_preprocessing_state.js";
|
import * as catalogPreprocessingStateMigration from "./migrations/013_catalog_preprocessing_state.js";
|
||||||
|
import * as installationBindingImportsMigration from "./migrations/014_installation_binding_imports.js";
|
||||||
|
import * as preprocessingRunIdentityMigration from "./migrations/015_preprocessing_run_identity.js";
|
||||||
|
|
||||||
const connectionString = process.env.THT_CATALOG_MIGRATOR_DATABASE_URL;
|
const connectionString = process.env.THT_CATALOG_MIGRATOR_DATABASE_URL;
|
||||||
const host = process.env.THT_CATALOG_DB_HOST;
|
const host = process.env.THT_CATALOG_DB_HOST;
|
||||||
@@ -54,6 +56,8 @@ const provider: MigrationProvider = {
|
|||||||
"011_local_sensitivity_analysis": localSensitivityAnalysisMigration,
|
"011_local_sensitivity_analysis": localSensitivityAnalysisMigration,
|
||||||
"012_sensitivity_reason": sensitivityReasonMigration,
|
"012_sensitivity_reason": sensitivityReasonMigration,
|
||||||
"013_catalog_preprocessing_state": catalogPreprocessingStateMigration,
|
"013_catalog_preprocessing_state": catalogPreprocessingStateMigration,
|
||||||
|
"014_installation_binding_imports": installationBindingImportsMigration,
|
||||||
|
"015_preprocessing_run_identity": preprocessingRunIdentityMigration,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { type Kysely, sql } from "kysely";
|
||||||
|
import type { CatalogDatabase } from "../repository.js";
|
||||||
|
|
||||||
|
/** Import receipts survive administrative deletion; they contain no credentials or configuration. */
|
||||||
|
export async function up(db: Kysely<CatalogDatabase>): Promise<void> {
|
||||||
|
await db.schema.createTable("installation_binding_imports")
|
||||||
|
.addColumn("workspace_id", "text", column => column.primaryKey())
|
||||||
|
// Deliberately no cascading FK: absence of a previously imported database requires reconciliation.
|
||||||
|
.addColumn("database_id", "uuid", column => column.notNull().unique())
|
||||||
|
.addColumn("created_at", "timestamptz", column => column.notNull().defaultTo(sql`now()`))
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(db: Kysely<CatalogDatabase>): Promise<void> {
|
||||||
|
await db.schema.dropTable("installation_binding_imports").execute();
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import type { Kysely } from "kysely";
|
||||||
|
import type { CatalogDatabase } from "../repository.js";
|
||||||
|
|
||||||
|
/** Fences late completions when recovery repeats exactly the same input revision. */
|
||||||
|
export async function up(db: Kysely<CatalogDatabase>): Promise<void> {
|
||||||
|
await db.schema.alterTable("workspace_databases")
|
||||||
|
.addColumn("preprocessing_run_id", "text").execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(db: Kysely<CatalogDatabase>): Promise<void> {
|
||||||
|
await db.schema.alterTable("workspace_databases")
|
||||||
|
.dropColumn("preprocessing_run_id").execute();
|
||||||
|
}
|
||||||
@@ -76,6 +76,7 @@ interface WorkspaceDatabaseTable {
|
|||||||
metadataContentRevision: Generated<number>;
|
metadataContentRevision: Generated<number>;
|
||||||
preprocessingStatus: Generated<WorkspaceDatabase["preprocessingStatus"]>;
|
preprocessingStatus: Generated<WorkspaceDatabase["preprocessingStatus"]>;
|
||||||
preprocessingInputFingerprint: Generated<string | null>;
|
preprocessingInputFingerprint: Generated<string | null>;
|
||||||
|
preprocessingRunId: Generated<string | null>;
|
||||||
preprocessedMetadataRevision: Generated<number | null>;
|
preprocessedMetadataRevision: Generated<number | null>;
|
||||||
preprocessingStartedAt: NullableTimestamp;
|
preprocessingStartedAt: NullableTimestamp;
|
||||||
preprocessingFinishedAt: NullableTimestamp;
|
preprocessingFinishedAt: NullableTimestamp;
|
||||||
@@ -273,6 +274,7 @@ interface CatalogSyncEventTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CatalogDatabase {
|
export interface CatalogDatabase {
|
||||||
|
installationBindingImports: { workspaceId: string; databaseId: string; createdAt: Generated<Date> };
|
||||||
workspaceDatabases: WorkspaceDatabaseTable;
|
workspaceDatabases: WorkspaceDatabaseTable;
|
||||||
databaseBindings: DatabaseBindingTable;
|
databaseBindings: DatabaseBindingTable;
|
||||||
catalogTables: CatalogTableTable;
|
catalogTables: CatalogTableTable;
|
||||||
@@ -342,6 +344,7 @@ function serialize(row: JoinedRow): WorkspaceDatabase {
|
|||||||
metadataContentRevision: Number(row.metadataContentRevision),
|
metadataContentRevision: Number(row.metadataContentRevision),
|
||||||
preprocessingStatus: row.preprocessingStatus,
|
preprocessingStatus: row.preprocessingStatus,
|
||||||
preprocessingInputFingerprint: present(row.preprocessingInputFingerprint),
|
preprocessingInputFingerprint: present(row.preprocessingInputFingerprint),
|
||||||
|
preprocessingRunId: present(row.preprocessingRunId),
|
||||||
preprocessedMetadataRevision: row.preprocessedMetadataRevision == null
|
preprocessedMetadataRevision: row.preprocessedMetadataRevision == null
|
||||||
? undefined
|
? undefined
|
||||||
: Number(row.preprocessedMetadataRevision),
|
: Number(row.preprocessedMetadataRevision),
|
||||||
@@ -507,6 +510,7 @@ export class KyselyCatalogRepository implements CatalogRepository {
|
|||||||
async beginPreprocessing(
|
async beginPreprocessing(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
|
runId?: string,
|
||||||
): Promise<CatalogPreprocessingStartResult> {
|
): Promise<CatalogPreprocessingStartResult> {
|
||||||
return await this.db.transaction().execute(async (trx) => {
|
return await this.db.transaction().execute(async (trx) => {
|
||||||
const database = await trx.selectFrom("workspaceDatabases")
|
const database = await trx.selectFrom("workspaceDatabases")
|
||||||
@@ -539,6 +543,7 @@ export class KyselyCatalogRepository implements CatalogRepository {
|
|||||||
.set({
|
.set({
|
||||||
preprocessingStatus: "running",
|
preprocessingStatus: "running",
|
||||||
preprocessingInputFingerprint: inputFingerprint,
|
preprocessingInputFingerprint: inputFingerprint,
|
||||||
|
preprocessingRunId: runId ?? null,
|
||||||
preprocessedMetadataRevision: null,
|
preprocessedMetadataRevision: null,
|
||||||
preprocessingStartedAt: sql`now()`,
|
preprocessingStartedAt: sql`now()`,
|
||||||
preprocessingFinishedAt: null,
|
preprocessingFinishedAt: null,
|
||||||
@@ -556,6 +561,7 @@ export class KyselyCatalogRepository implements CatalogRepository {
|
|||||||
metadataContentRevision: number,
|
metadataContentRevision: number,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
||||||
|
runId?: string,
|
||||||
): Promise<WorkspaceDatabase | undefined> {
|
): Promise<WorkspaceDatabase | undefined> {
|
||||||
const result = await this.db.updateTable("workspaceDatabases")
|
const result = await this.db.updateTable("workspaceDatabases")
|
||||||
.set({
|
.set({
|
||||||
@@ -569,6 +575,7 @@ export class KyselyCatalogRepository implements CatalogRepository {
|
|||||||
.where("preprocessingStatus", "=", "running")
|
.where("preprocessingStatus", "=", "running")
|
||||||
.where("metadataContentRevision", "=", metadataContentRevision)
|
.where("metadataContentRevision", "=", metadataContentRevision)
|
||||||
.where("preprocessingInputFingerprint", "=", inputFingerprint)
|
.where("preprocessingInputFingerprint", "=", inputFingerprint)
|
||||||
|
.where("preprocessingRunId", runId === undefined ? "is" : "=", runId ?? null)
|
||||||
.returning("id")
|
.returning("id")
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
return result ? await this.get(result.id) : undefined;
|
return result ? await this.get(result.id) : undefined;
|
||||||
@@ -681,10 +688,11 @@ export class KyselyCatalogRepository implements CatalogRepository {
|
|||||||
}, row.updatedAt === null ? null : new Date(row.updatedAt).toISOString());
|
}, row.updatedAt === null ? null : new Date(row.updatedAt).toISOString());
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(input: DatabaseConfigurationInput): Promise<WorkspaceDatabase> {
|
async create(input: DatabaseConfigurationInput, creationId?: string): Promise<WorkspaceDatabase> {
|
||||||
try {
|
try {
|
||||||
return await this.db.transaction().execute(async (trx) => {
|
return await this.db.transaction().execute(async (trx) => {
|
||||||
const id = randomUUID();
|
const id = creationId ?? randomUUID();
|
||||||
|
if (creationId) await trx.insertInto("installationBindingImports").values({ workspaceId: input.workspaceId, databaseId: id }).execute();
|
||||||
await trx.insertInto("workspaceDatabases").values({
|
await trx.insertInto("workspaceDatabases").values({
|
||||||
id,
|
id,
|
||||||
workspaceId: input.workspaceId,
|
workspaceId: input.workspaceId,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export interface WorkspaceDatabase {
|
|||||||
metadataContentRevision: number;
|
metadataContentRevision: number;
|
||||||
preprocessingStatus: CatalogPreprocessingStatus;
|
preprocessingStatus: CatalogPreprocessingStatus;
|
||||||
preprocessingInputFingerprint?: string;
|
preprocessingInputFingerprint?: string;
|
||||||
|
preprocessingRunId?: string;
|
||||||
preprocessedMetadataRevision?: number;
|
preprocessedMetadataRevision?: number;
|
||||||
preprocessingStartedAt?: string;
|
preprocessingStartedAt?: string;
|
||||||
preprocessingFinishedAt?: string;
|
preprocessingFinishedAt?: string;
|
||||||
@@ -453,16 +454,18 @@ export interface CatalogRepository {
|
|||||||
beginPreprocessing(
|
beginPreprocessing(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
|
runId?: string,
|
||||||
): Promise<CatalogPreprocessingStartResult>;
|
): Promise<CatalogPreprocessingStartResult>;
|
||||||
finishPreprocessing(
|
finishPreprocessing(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
metadataContentRevision: number,
|
metadataContentRevision: number,
|
||||||
inputFingerprint: string,
|
inputFingerprint: string,
|
||||||
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
outcome: { status: "succeeded" } | { status: "failed"; errorCode: string },
|
||||||
|
runId?: string,
|
||||||
): Promise<WorkspaceDatabase | undefined>;
|
): Promise<WorkspaceDatabase | undefined>;
|
||||||
clearPreprocessing(workspaceId: string): Promise<CatalogPreprocessingClearResult>;
|
clearPreprocessing(workspaceId: string): Promise<CatalogPreprocessingClearResult>;
|
||||||
getCatalogMetrics(databaseId?: string): Promise<CatalogMetrics | undefined>;
|
getCatalogMetrics(databaseId?: string): Promise<CatalogMetrics | undefined>;
|
||||||
create(input: DatabaseConfigurationInput): Promise<WorkspaceDatabase>;
|
create(input: DatabaseConfigurationInput, creationId?: string): Promise<WorkspaceDatabase>;
|
||||||
update(id: string, expectedVersion: number, input: DatabaseConfigurationInput): Promise<WorkspaceDatabase | undefined>;
|
update(id: string, expectedVersion: number, input: DatabaseConfigurationInput): Promise<WorkspaceDatabase | undefined>;
|
||||||
recordTest(id: string, expectedVersion: number, result: DatabaseTestResult): Promise<WorkspaceDatabase | undefined>;
|
recordTest(id: string, expectedVersion: number, result: DatabaseTestResult): Promise<WorkspaceDatabase | undefined>;
|
||||||
touch(id: string, expectedVersion: number): Promise<WorkspaceDatabase | undefined>;
|
touch(id: string, expectedVersion: number): Promise<WorkspaceDatabase | undefined>;
|
||||||
|
|||||||
@@ -41,8 +41,11 @@ const runtimeModelSchema = z.object({
|
|||||||
supportsReasoningEffort: z.boolean(),
|
supportsReasoningEffort: z.boolean(),
|
||||||
supportsStore: z.boolean(),
|
supportsStore: z.boolean(),
|
||||||
maxTokensField: z.string().optional(),
|
maxTokensField: z.string().optional(),
|
||||||
|
thinkingFormat: z.enum(["qwen", "qwen-chat-template"]).optional(),
|
||||||
}).strict().optional(),
|
}).strict().optional(),
|
||||||
}).strict().optional(),
|
}).strict().refine((session) => !session.compatibility?.thinkingFormat || session.reasoning, {
|
||||||
|
message: "thinkingFormat requires reasoning: true",
|
||||||
|
}).optional(),
|
||||||
metadataGeneration: z.object({ disableThinking: z.boolean() }).strict().optional(),
|
metadataGeneration: z.object({ disableThinking: z.boolean() }).strict().optional(),
|
||||||
}).strict();
|
}).strict();
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ import { loadSettings } from "./settings/settings-store.js";
|
|||||||
import { ThtRunner, type SessionRow } from "./tht/tht-runner.js";
|
import { ThtRunner, type SessionRow } from "./tht/tht-runner.js";
|
||||||
import { WorkspaceRegistry } from "./workspaces/registry.js";
|
import { WorkspaceRegistry } from "./workspaces/registry.js";
|
||||||
import { WorkspaceSecretStore } from "./workspaces/secret-store.js";
|
import { WorkspaceSecretStore } from "./workspaces/secret-store.js";
|
||||||
|
import { createProductionWorkspaceDiagnoser } from "./workspaces/diagnostics.js";
|
||||||
|
import { resolveCatalogRuntimeBinding } from "./catalog/runtime-binding.js";
|
||||||
|
import { CatalogService } from "./catalog/service.js";
|
||||||
|
import { validateOperationalWorkspace } from "./workspaces/schema.js";
|
||||||
import { createCatalogRepository } from "./catalog/repository.js";
|
import { createCatalogRepository } from "./catalog/repository.js";
|
||||||
import type { CatalogRepository } from "./catalog/types.js";
|
import type { CatalogRepository } from "./catalog/types.js";
|
||||||
|
|
||||||
type OperatorAction = "maintenance-activate" | "maintenance-deactivate" | "maintenance-status"
|
type OperatorAction = "maintenance-activate" | "maintenance-deactivate" | "maintenance-status"
|
||||||
| "session-inventory" | "workflow-doctor" | "workspace-integrity"
|
| "session-inventory" | "workflow-doctor" | "workspace-integrity"
|
||||||
| "pi-test" | "effective-settings";
|
| "workspace-pull" | "workspace-test" | "pi-test" | "effective-settings";
|
||||||
|
|
||||||
const lifecyclePrincipal: PrincipalContext = {
|
const lifecyclePrincipal: PrincipalContext = {
|
||||||
issuer: "tht-operator-command",
|
issuer: "tht-operator-command",
|
||||||
@@ -119,6 +123,119 @@ async function workspaceIntegrity(config: AppConfig): Promise<{
|
|||||||
return { ready: true, ...integrity };
|
return { ready: true, ...integrity };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function workspacePull(config: AppConfig): Promise<{
|
||||||
|
ready: boolean;
|
||||||
|
status: "succeeded" | "degraded";
|
||||||
|
branch: string;
|
||||||
|
head?: string;
|
||||||
|
degraded: boolean;
|
||||||
|
}> {
|
||||||
|
const status = await new WorkspaceRegistry(config.workspaceRegistry).pull();
|
||||||
|
return {
|
||||||
|
ready: !status.degraded,
|
||||||
|
status: status.degraded ? "degraded" : "succeeded",
|
||||||
|
branch: status.branch,
|
||||||
|
...(status.head ? { head: status.head } : {}),
|
||||||
|
degraded: status.degraded,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WorkspaceTestReport {
|
||||||
|
id: string;
|
||||||
|
status: "ready" | "failed";
|
||||||
|
database: "reachable" | "not_configured" | "failed";
|
||||||
|
diagnostics: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function workspaceTest(config: AppConfig): Promise<{
|
||||||
|
ready: boolean;
|
||||||
|
workspaces: WorkspaceTestReport[];
|
||||||
|
}> {
|
||||||
|
if (!config.catalogDatabase) throw new Error("Catalog database is not configured");
|
||||||
|
const registry = new WorkspaceRegistry(config.workspaceRegistry);
|
||||||
|
const revisions = await registry.list();
|
||||||
|
const repository = createCatalogRepository(config.catalogDatabase);
|
||||||
|
try {
|
||||||
|
const secretStore = new WorkspaceSecretStore({
|
||||||
|
root: config.workspaceSecretStoreRoot,
|
||||||
|
runtimeRoot: config.workspaceSecretRuntimeRoot,
|
||||||
|
installationId: config.workspaceRegistry.installationId,
|
||||||
|
});
|
||||||
|
const catalogService = new CatalogService(
|
||||||
|
repository,
|
||||||
|
registry,
|
||||||
|
secretStore,
|
||||||
|
config.workspaceRegistry.secretRoots,
|
||||||
|
config.workspaceDiagnosticTimeoutMs,
|
||||||
|
);
|
||||||
|
const diagnose = createProductionWorkspaceDiagnoser(config.workspaceDiagnosticTimeoutMs, undefined, {
|
||||||
|
internalQdrantUrl: config.internalQdrantUrl,
|
||||||
|
internalEmbeddingUrl: config.internalEmbeddingUrl,
|
||||||
|
internalEmbeddingId: config.internalEmbeddingId,
|
||||||
|
internalEmbeddingModel: config.internalEmbeddingModel,
|
||||||
|
internalEmbeddingDimensions: config.internalEmbeddingDimensions,
|
||||||
|
});
|
||||||
|
const databases = await repository.list();
|
||||||
|
const reports: WorkspaceTestReport[] = [];
|
||||||
|
for (const revision of revisions) {
|
||||||
|
const diagnostics: string[] = [];
|
||||||
|
let workspace: ReturnType<typeof validateOperationalWorkspace>;
|
||||||
|
try {
|
||||||
|
workspace = validateOperationalWorkspace((await registry.read(revision.id)).workspace);
|
||||||
|
} catch {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "not_configured", diagnostics: ["workspace_invalid"] });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const database = databases.find((candidate) => candidate.workspaceId === revision.id);
|
||||||
|
if (!database) {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "not_configured", diagnostics: ["database_binding_missing"] });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let tested;
|
||||||
|
try {
|
||||||
|
tested = await catalogService.test(database);
|
||||||
|
} catch {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "failed", diagnostics: ["database_unreachable"] });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!tested || tested.connectionStatus !== "reachable") {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "failed", diagnostics: ["database_unreachable"] });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let lease: ReturnType<typeof resolveCatalogRuntimeBinding>;
|
||||||
|
try {
|
||||||
|
lease = resolveCatalogRuntimeBinding({
|
||||||
|
workspace,
|
||||||
|
database: tested,
|
||||||
|
environment: process.env,
|
||||||
|
secretRoots: config.workspaceRegistry.secretRoots,
|
||||||
|
secretStore,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "reachable", diagnostics: ["binding_missing"] });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// CatalogService.test() above is the authoritative database probe and records its
|
||||||
|
// outcome. The remaining diagnoser pass checks Evidence and internal semantic services;
|
||||||
|
// skipping its legacy DWH probe avoids requiring a second response-shape contract for a
|
||||||
|
// REST health endpoint.
|
||||||
|
const result = await diagnose(lease.workspace, lease.bindings, { writeProbe: false, skipDwh: true });
|
||||||
|
diagnostics.push(...result.diagnostics.map((diagnostic) => diagnostic.code));
|
||||||
|
const ready = result.activatable;
|
||||||
|
reports.push({ id: revision.id, status: ready ? "ready" : "failed", database: "reachable", diagnostics });
|
||||||
|
} catch {
|
||||||
|
reports.push({ id: revision.id, status: "failed", database: "reachable", diagnostics: ["connector_unavailable"] });
|
||||||
|
} finally {
|
||||||
|
lease.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { ready: reports.length > 0 && reports.every((report) => report.status === "ready"), workspaces: reports };
|
||||||
|
} finally {
|
||||||
|
await repository.close?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function runOperatorAction(
|
export async function runOperatorAction(
|
||||||
action: OperatorAction,
|
action: OperatorAction,
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
@@ -132,6 +249,8 @@ export async function runOperatorAction(
|
|||||||
if (action === "session-inventory") return await sessionInventory(config);
|
if (action === "session-inventory") return await sessionInventory(config);
|
||||||
if (action === "workflow-doctor") return await workflowDiagnostics(config);
|
if (action === "workflow-doctor") return await workflowDiagnostics(config);
|
||||||
if (action === "workspace-integrity") return await workspaceIntegrity(config);
|
if (action === "workspace-integrity") return await workspaceIntegrity(config);
|
||||||
|
if (action === "workspace-pull") return await workspacePull(config);
|
||||||
|
if (action === "workspace-test") return await workspaceTest(config);
|
||||||
const modelCatalog = loadRuntimeModelCatalog(config.modelCatalogFile);
|
const modelCatalog = loadRuntimeModelCatalog(config.modelCatalogFile);
|
||||||
if (action === "effective-settings") {
|
if (action === "effective-settings") {
|
||||||
return effectiveSettings(config, loadSettings(config), modelCatalog);
|
return effectiveSettings(config, loadSettings(config), modelCatalog);
|
||||||
@@ -146,6 +265,7 @@ async function main(): Promise<void> {
|
|||||||
if (!action || ![
|
if (!action || ![
|
||||||
"maintenance-activate", "maintenance-deactivate", "maintenance-status", "session-inventory",
|
"maintenance-activate", "maintenance-deactivate", "maintenance-status", "session-inventory",
|
||||||
"workflow-doctor", "workspace-integrity", "pi-test", "effective-settings",
|
"workflow-doctor", "workspace-integrity", "pi-test", "effective-settings",
|
||||||
|
"workspace-pull", "workspace-test",
|
||||||
].includes(action)) throw new Error("invalid operator action");
|
].includes(action)) throw new Error("invalid operator action");
|
||||||
const result = await runOperatorAction(action, loadConfig(process.env));
|
const result = await runOperatorAction(action, loadConfig(process.env));
|
||||||
process.stdout.write(`${JSON.stringify(result)}\n`);
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export function createPiManagement(config: AppConfig, deps: PiManagementDeps): P
|
|||||||
|
|
||||||
const installationConfig = (): PiInstallationConfig => {
|
const installationConfig = (): PiInstallationConfig => {
|
||||||
const settings = readSettings();
|
const settings = readSettings();
|
||||||
const reasoning = config.defaults.thinking ?? settings.thinking;
|
const reasoning = config.defaults.thinking ?? settings.thinking ?? "low";
|
||||||
const selected = deps.modelCatalog.defaultInteraction
|
const selected = deps.modelCatalog.defaultInteraction
|
||||||
? splitCanonicalModelId(deps.modelCatalog.defaultInteraction)
|
? splitCanonicalModelId(deps.modelCatalog.defaultInteraction)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|||||||
@@ -1,60 +1,19 @@
|
|||||||
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { isPrincipalContext, requirePermission } from "../auth/authorization.js";
|
import { isPrincipalContext, requirePermission } from "../auth/authorization.js";
|
||||||
import { parseCredentialFreeHttpUrl } from "../auth/url-policy.js";
|
import { databaseConfigurationSchema as configSchema } from "../catalog/configuration-schema.js";
|
||||||
import { CatalogService, type CatalogSecretName } from "../catalog/service.js";
|
import { CatalogService, type CatalogSecretName } from "../catalog/service.js";
|
||||||
import { WorkspaceRegistryError } from "../workspaces/git-repository.js";
|
import { WorkspaceRegistryError } from "../workspaces/git-repository.js";
|
||||||
import {
|
import {
|
||||||
CatalogConflictError,
|
CatalogConflictError,
|
||||||
CatalogOperationInProgressError,
|
CatalogOperationInProgressError,
|
||||||
CatalogUnavailableError,
|
CatalogUnavailableError,
|
||||||
DATABASE_TRANSPORTS,
|
|
||||||
type CatalogRepository,
|
type CatalogRepository,
|
||||||
type DatabaseConfigurationInput,
|
type DatabaseConfigurationInput,
|
||||||
} from "../catalog/types.js";
|
} from "../catalog/types.js";
|
||||||
import type { CatalogOperationCoordinator } from "../catalog/operation-coordinator.js";
|
import type { CatalogOperationCoordinator } from "../catalog/operation-coordinator.js";
|
||||||
|
|
||||||
const idSchema = z.uuid();
|
const idSchema = z.uuid();
|
||||||
const workspaceIdSchema = z.string().regex(/^[a-z][a-z0-9-]{2,62}$/);
|
|
||||||
const identifier = z.string().trim().min(1).max(128).regex(/^[A-Za-z_][A-Za-z0-9_$-]*$/);
|
|
||||||
const nonEmpty = z.string().trim().min(1).max(512);
|
|
||||||
const port = z.number().int().min(1).max(65_535);
|
|
||||||
const optionalText = nonEmpty.optional();
|
|
||||||
const sshHost = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9_.:\[\]-]+$/).optional();
|
|
||||||
const sshUsername = z.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/).optional();
|
|
||||||
const bindingSchema = z.object({
|
|
||||||
transport: z.enum(DATABASE_TRANSPORTS),
|
|
||||||
host: optionalText,
|
|
||||||
port: port.optional(),
|
|
||||||
username: optionalText,
|
|
||||||
baseUrl: z.string().max(2048)
|
|
||||||
.refine((value) => parseCredentialFreeHttpUrl(value) !== undefined)
|
|
||||||
.optional(),
|
|
||||||
restPath: z.string().regex(/^\/(?!\/)[^?#\\\u0000-\u001f]*$/).max(512).optional(),
|
|
||||||
restAuth: z.enum(["none", "bearer", "x-api-key"]).optional(),
|
|
||||||
tlsServername: optionalText,
|
|
||||||
sshHost,
|
|
||||||
sshPort: port.optional(),
|
|
||||||
sshUsername,
|
|
||||||
sshTargetHost: sshHost,
|
|
||||||
sshTargetPort: port.optional(),
|
|
||||||
}).strict().superRefine((binding, context) => {
|
|
||||||
const required = binding.transport === "postgres_direct"
|
|
||||||
? ["host", "port", "username"] as const
|
|
||||||
: binding.transport === "rest_api"
|
|
||||||
? ["baseUrl", "restPath", "restAuth"] as const
|
|
||||||
: ["username", "sshHost", "sshPort", "sshUsername", "sshTargetHost", "sshTargetPort"] as const;
|
|
||||||
for (const field of required) {
|
|
||||||
if (binding[field] === undefined) context.addIssue({ code: "custom", path: [field], message: "Required" });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const configSchema = z.object({
|
|
||||||
workspaceId: workspaceIdSchema,
|
|
||||||
engine: z.literal("postgres"),
|
|
||||||
databaseName: identifier,
|
|
||||||
schema: identifier,
|
|
||||||
binding: bindingSchema,
|
|
||||||
}).strict();
|
|
||||||
const updateSchema = configSchema.extend({ version: z.number().int().positive() });
|
const updateSchema = configSchema.extend({ version: z.number().int().positive() });
|
||||||
const secretNames = [
|
const secretNames = [
|
||||||
"password",
|
"password",
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import type { FastifyInstance } from "fastify";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { isPrincipalContext, requirePermission } from "../auth/authorization.js";
|
||||||
|
import { InstallationBindings, InstallationReconciliationRequired } from "../catalog/installation-bindings.js";
|
||||||
|
import { CatalogConflictError, CatalogOperationInProgressError } from "../catalog/types.js";
|
||||||
|
import type { WorkspaceRegistry } from "../workspaces/registry.js";
|
||||||
|
|
||||||
|
const sourceSchema = z.object({ remote: z.string().min(1).max(4096), branch: z.string().min(1).max(256),
|
||||||
|
revision: z.string().regex(/^(?:[a-f0-9]{40}|content-snapshot)$/),
|
||||||
|
files: z.record(z.string().min(1).max(4096), z.string().regex(/^[a-f0-9]{64}$/))
|
||||||
|
.refine(files => Object.keys(files).length > 0 && Object.keys(files).length <= 10000),
|
||||||
|
}).strict();
|
||||||
|
|
||||||
|
export function installationRoutes(app: FastifyInstance, bindings: InstallationBindings, registry: WorkspaceRegistry): void {
|
||||||
|
app.post("/installation/workspace-source", { bodyLimit: 2 * 1024 * 1024 }, async (request, reply) => {
|
||||||
|
if (!isPrincipalContext(requirePermission(request, reply, "workspace.manage"))) return reply;
|
||||||
|
try { return await registry.prepareInstallation(sourceSchema.parse(request.body)); }
|
||||||
|
catch (error) {
|
||||||
|
return reply.code(error instanceof z.ZodError ? 400 : 409).send({ code: "installation_workspace_reconciliation_required" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
app.post("/installation/bindings", { bodyLimit: 1024 * 1024 }, async (request, reply) => {
|
||||||
|
for (const permission of ["workspace.manage", "database.manage", "workspace.secrets.manage"] as const) {
|
||||||
|
if (!isPrincipalContext(requirePermission(request, reply, permission))) return reply;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const result = await bindings.apply(request.body);
|
||||||
|
return reply.code(result.connectionStatus === "reachable" ? 200 : 422).send(result);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof z.ZodError) return reply.code(400).send({ code: "installation_input_invalid" });
|
||||||
|
if (error instanceof CatalogOperationInProgressError) return reply.code(409).send({ code: "installation_operation_pending" });
|
||||||
|
if (error instanceof InstallationReconciliationRequired || error instanceof CatalogConflictError) {
|
||||||
|
return reply.code(409).send({ code: "installation_reconciliation_required" });
|
||||||
|
}
|
||||||
|
return reply.code(503).send({ code: "installation_binding_unavailable" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -509,12 +509,15 @@ export function sessionRoutes(
|
|||||||
// registry snapshot. The legacy fallback stays available for sessions created before
|
// registry snapshot. The legacy fallback stays available for sessions created before
|
||||||
// the browser-local preference migration.
|
// the browser-local preference migration.
|
||||||
let id: string;
|
let id: string;
|
||||||
|
let sessionLanguage = language;
|
||||||
try {
|
try {
|
||||||
({ id } = await runner.sessionNew({
|
const created = await runner.sessionNew({
|
||||||
question: b.question, name: b.name, workspaceConfigPath,
|
question: b.question, name: b.name, workspaceConfigPath,
|
||||||
workspaceId, workspaceRevision, provider, model, thinking,
|
workspaceId, workspaceRevision, provider, model, thinking,
|
||||||
interactionLanguage: language,
|
interactionLanguage: language,
|
||||||
}));
|
});
|
||||||
|
id = created.id;
|
||||||
|
sessionLanguage = created.interaction_language ?? language;
|
||||||
manifestPersisted = true;
|
manifestPersisted = true;
|
||||||
if (revisionLease) {
|
if (revisionLease) {
|
||||||
await revisionLease.markPersisted().catch((error: unknown) => {
|
await revisionLease.markPersisted().catch((error: unknown) => {
|
||||||
@@ -527,7 +530,7 @@ export function sessionRoutes(
|
|||||||
} catch { return storageFailure(reply); }
|
} catch { return storageFailure(reply); }
|
||||||
const options = {
|
const options = {
|
||||||
provider, model, thinking,
|
provider, model, thinking,
|
||||||
interactionLanguage: language,
|
interactionLanguage: sessionLanguage,
|
||||||
author: principal.displayName ?? principal.subject,
|
author: principal.displayName ?? principal.subject,
|
||||||
principal,
|
principal,
|
||||||
question: b.question,
|
question: b.question,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { ThtRunner } from "../tht/tht-runner.js";
|
|||||||
import type { WorkspacePreprocessingService } from "../workspaces/preprocessing-service.js";
|
import type { WorkspacePreprocessingService } from "../workspaces/preprocessing-service.js";
|
||||||
import type { PreprocessingJobState } from "../workspaces/preprocessing-state.js";
|
import type { PreprocessingJobState } from "../workspaces/preprocessing-state.js";
|
||||||
import type { WorkspaceRegistry } from "../workspaces/registry.js";
|
import type { WorkspaceRegistry } from "../workspaces/registry.js";
|
||||||
|
import { PreprocessingStateError } from "../workspaces/preprocessing-state.js";
|
||||||
|
|
||||||
const workspaceIdSchema = z.string().regex(/^[a-z][a-z0-9-]{2,62}$/);
|
const workspaceIdSchema = z.string().regex(/^[a-z][a-z0-9-]{2,62}$/);
|
||||||
const ACTIVE_SYNC_STATES = new Set(["queued", "running", "awaiting_confirmation", "applying"]);
|
const ACTIVE_SYNC_STATES = new Set(["queued", "running", "awaiting_confirmation", "applying"]);
|
||||||
@@ -317,6 +318,9 @@ export async function readWorkspacePreprocessingStatus(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function safeError(reply: FastifyReply, error: unknown) {
|
function safeError(reply: FastifyReply, error: unknown) {
|
||||||
|
if (error instanceof PreprocessingStateError) {
|
||||||
|
return reply.code(409).send({ code: "preprocessing_conflict", state: "running", message: "Preprocessing is still owned by another process." });
|
||||||
|
}
|
||||||
if (error instanceof CatalogUnavailableError) {
|
if (error instanceof CatalogUnavailableError) {
|
||||||
return reply.code(503).send({
|
return reply.code(503).send({
|
||||||
code: "catalog_unavailable",
|
code: "catalog_unavailable",
|
||||||
@@ -357,7 +361,8 @@ export function workspacePreprocessingRoutes(
|
|||||||
try {
|
try {
|
||||||
const workspaceId = workspaceIdFrom(request);
|
const workspaceId = workspaceIdFrom(request);
|
||||||
const before = await readWorkspacePreprocessingStatus(workspaceId, deps);
|
const before = await readWorkspacePreprocessingStatus(workspaceId, deps);
|
||||||
if (!before.actionable) {
|
const options = z.object({ recoverInterrupted: z.boolean().optional() }).strict().parse(request.body ?? {});
|
||||||
|
if (!before.actionable && !(before.state === "running" && options.recoverInterrupted)) {
|
||||||
return reply.code(409).send({ ...before, code: "preprocessing_blocked" });
|
return reply.code(409).send({ ...before, code: "preprocessing_blocked" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ export class ThtRunner {
|
|||||||
if (v) a.push(f, v);
|
if (v) a.push(f, v);
|
||||||
}
|
}
|
||||||
a.push("--json");
|
a.push("--json");
|
||||||
return this.json<{ id: string }>(a, o.workspaceConfigPath ?? o.workspace);
|
return this.json<{ id: string; interaction_language?: string }>(a, o.workspaceConfigPath ?? o.workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build and persist the deterministic F1 retrieval pack for a new session. */
|
/** Build and persist the deterministic F1 retrieval pack for a new session. */
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/** Compiled with its runtime for the host CLI: no installation, Docker or host Node required. */
|
||||||
|
import { runWorkspaceDocuments } from "./workspaces/documents.js";
|
||||||
|
import { runBootstrapValidation } from "./catalog/bootstrap-cli.js";
|
||||||
|
import { runBootstrapProbes } from "./catalog/bootstrap-probes.js";
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const result = args[0] === "probe" ? await runBootstrapProbes(args.slice(1))
|
||||||
|
: args[0] === "bootstrap" ? runBootstrapValidation(args.slice(1)) : runWorkspaceDocuments(args);
|
||||||
|
console.log(result.output);
|
||||||
|
process.exitCode = result.status;
|
||||||
@@ -9,6 +9,7 @@ import { WorkspaceSecretStore } from "./workspaces/secret-store.js";
|
|||||||
import { WorkspacePreprocessingService, type WorkspaceOperationResult } from "./workspaces/preprocessing-service.js";
|
import { WorkspacePreprocessingService, type WorkspaceOperationResult } from "./workspaces/preprocessing-service.js";
|
||||||
import { createCatalogRepository } from "./catalog/repository.js";
|
import { createCatalogRepository } from "./catalog/repository.js";
|
||||||
import type { CatalogRepository } from "./catalog/types.js";
|
import type { CatalogRepository } from "./catalog/types.js";
|
||||||
|
import { guardedPreprocessingCommand } from "./workspaces/preprocessing-owner.js";
|
||||||
|
|
||||||
export interface WorkspaceMaintenanceIo {
|
export interface WorkspaceMaintenanceIo {
|
||||||
stdin: string;
|
stdin: string;
|
||||||
@@ -238,7 +239,7 @@ export function createProductionWorkspacePreprocessingService(
|
|||||||
active.releaseSecrets();
|
active.releaseSecrets();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
runChild: async ({ argv, configPath }) => {
|
runChild: async ({ argv, configPath, guard }) => {
|
||||||
const configFd = openSync(configPath, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
const configFd = openSync(configPath, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
||||||
try {
|
try {
|
||||||
return await new Promise((resolve) => {
|
return await new Promise((resolve) => {
|
||||||
@@ -254,7 +255,8 @@ export function createProductionWorkspacePreprocessingService(
|
|||||||
"THT_CATALOG_MIGRATOR_USER",
|
"THT_CATALOG_MIGRATOR_USER",
|
||||||
"THT_CATALOG_MIGRATOR_PASSWORD_FILE",
|
"THT_CATALOG_MIGRATOR_PASSWORD_FILE",
|
||||||
]) delete childEnvironment[name];
|
]) delete childEnvironment[name];
|
||||||
const child = spawn(config.thtBin, argv, {
|
const command = guard ? guardedPreprocessingCommand(guard, config.thtBin, argv) : { executable: config.thtBin, args: argv };
|
||||||
|
const child = spawn(command.executable, command.args, {
|
||||||
cwd: config.harnessDir,
|
cwd: config.harnessDir,
|
||||||
env: { ...childEnvironment, ...(config.dataRoot ? { THT_DATA_ROOT: config.dataRoot } : {}) },
|
env: { ...childEnvironment, ...(config.dataRoot ? { THT_DATA_ROOT: config.dataRoot } : {}) },
|
||||||
stdio: ["ignore", "pipe", "pipe", configFd],
|
stdio: ["ignore", "pipe", "pipe", configFd],
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ const catalogSchema = z.object({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function safeCatalogError(): Error {
|
function safeCatalogError(cause?: unknown): Error {
|
||||||
return new Error("Workspace catalog is invalid");
|
return new Error("Workspace catalog is invalid", { cause });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseWorkspaceCatalogYaml(source: string): WorkspaceCatalog {
|
export function parseWorkspaceCatalogYaml(source: string): WorkspaceCatalog {
|
||||||
@@ -57,7 +57,7 @@ export function parseWorkspaceCatalogYaml(source: string): WorkspaceCatalog {
|
|||||||
return catalogSchema.parse(document.toJSON()) as WorkspaceCatalog;
|
return catalogSchema.parse(document.toJSON()) as WorkspaceCatalog;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message === "Workspace catalog is invalid") throw error;
|
if (error instanceof Error && error.message === "Workspace catalog is invalid") throw error;
|
||||||
throw safeCatalogError();
|
throw safeCatalogError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
import { closeSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||||
|
import { join, resolve } from "node:path";
|
||||||
|
import { parseAllDocuments, stringify } from "yaml";
|
||||||
|
import { ZodError } from "zod";
|
||||||
|
import { CATALOG_PATH, parseWorkspaceCatalogYaml, assertCatalogMatchesDescriptor } from "./catalog.js";
|
||||||
|
import { parseWorkspaceYaml, type WorkspaceDescriptor } from "./schema.js";
|
||||||
|
|
||||||
|
interface Issue { document: string; field: string; code: string; correction: string; line?: number }
|
||||||
|
interface Report {
|
||||||
|
schema_version: 1;
|
||||||
|
scope: "local-documents";
|
||||||
|
ok: boolean;
|
||||||
|
workspaces: { id: string; evidence: "absent" | "local-files" | "remote-deferred" }[];
|
||||||
|
issues: Issue[];
|
||||||
|
deferred_checks: string[];
|
||||||
|
}
|
||||||
|
const MAX_DOCUMENT_BYTES = 1024 * 1024;
|
||||||
|
const usage = "tht workspace prepare --directory NEW_PATH --id ID --name NAME [--language en|it] [--json]\ntht workspace validate --directory PATH [--json]";
|
||||||
|
|
||||||
|
export class DocumentError extends Error {
|
||||||
|
constructor(readonly issue: Issue) { super(issue.correction); }
|
||||||
|
}
|
||||||
|
function fail(document: string, field: string, code: string, correction: string): never {
|
||||||
|
throw new DocumentError({ document, field, code, correction });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Never include parser messages or submitted values: YAML and Zod errors can contain secrets. */
|
||||||
|
export function decode<T>(source: string, document: string, parser: (text: string) => T, contract = "workspace schema v4 or catalog schema v1"): T {
|
||||||
|
try {
|
||||||
|
const documents = parseAllDocuments(source, { uniqueKeys: true });
|
||||||
|
if (documents.length !== 1) fail(document, "$", "yaml_documents", "Keep exactly one YAML document in this file.");
|
||||||
|
const problem = [...documents[0].errors, ...documents[0].warnings][0];
|
||||||
|
if (problem) {
|
||||||
|
throw new DocumentError({ document, field: "$", code: "yaml_syntax", line: problem.linePos?.[0].line,
|
||||||
|
correction: "Correct YAML syntax, remove duplicate keys and unsupported tags at the indicated line." });
|
||||||
|
}
|
||||||
|
return parser(source);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof DocumentError) throw error;
|
||||||
|
const cause = error instanceof Error && error.cause instanceof ZodError ? error.cause : error;
|
||||||
|
if (cause instanceof ZodError) {
|
||||||
|
const issue = cause.issues[0];
|
||||||
|
// Strict schemas produce paths containing schema-defined keys and array indices only.
|
||||||
|
fail(document, issue.path.join(".") || "$", "schema_invalid",
|
||||||
|
issue.code === "unrecognized_keys" ? "Remove fields not defined by the current workspace/catalog contract."
|
||||||
|
: `Correct this field using ${contract}; check type, required value, uniqueness and allowed values.`);
|
||||||
|
}
|
||||||
|
fail(document, "$", "schema_invalid", "Use an authored workspace v4 descriptor; remove database configuration and keep it in the PostgreSQL Metadata Catalog.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stat(root: string, document: string, directory: boolean) {
|
||||||
|
let info;
|
||||||
|
try { info = lstatSync(join(root, document)); }
|
||||||
|
catch { fail(document, "$", "missing_reference", "Create the referenced local file or directory and grant read access."); }
|
||||||
|
if (info.isSymbolicLink() || (directory ? !info.isDirectory() : !info.isFile())) {
|
||||||
|
fail(document, "$", "unsafe_reference", "Use a regular local file or directory, without symbolic links or special files.");
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
function readDocument(root: string, document: string): string {
|
||||||
|
if (stat(root, document, false).size > MAX_DOCUMENT_BYTES) {
|
||||||
|
fail(document, "$", "document_too_large", "Keep YAML documents below the 1 MiB local validation limit.");
|
||||||
|
}
|
||||||
|
try { return readFileSync(join(root, document), "utf8"); }
|
||||||
|
catch { fail(document, "$", "unreadable", "Grant read access to this document and retry validation."); }
|
||||||
|
}
|
||||||
|
function directories(root: string, document: string) {
|
||||||
|
stat(root, document, true);
|
||||||
|
try { return readdirSync(join(root, document), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name)); }
|
||||||
|
catch { fail(document, "$", "unreadable", "Grant read and traversal access to this directory and retry validation."); }
|
||||||
|
}
|
||||||
|
|
||||||
|
function inspectEvidence(root: string, descriptor: WorkspaceDescriptor): "absent" | "local-files" | "remote-deferred" {
|
||||||
|
const evidence = descriptor.evidence;
|
||||||
|
if (!evidence) return "absent";
|
||||||
|
if (evidence.source.type !== "filesystem") return "remote-deferred";
|
||||||
|
const base = evidence.source.uri;
|
||||||
|
stat(root, base, true);
|
||||||
|
if (evidence.schema_version === 2) stat(root, `${base}/curated`, true);
|
||||||
|
const patterns = evidence.source.patterns ?? ["**/*.md"];
|
||||||
|
const literals = patterns.filter((pattern) => !/[?*\[]/.test(pattern));
|
||||||
|
for (const pattern of literals) {
|
||||||
|
const parts = pattern.split("/");
|
||||||
|
for (let index = 1; index < parts.length; index++) stat(root, `${base}/${parts.slice(0, index).join("/")}`, true);
|
||||||
|
stat(root, `${base}/${pattern}`, false);
|
||||||
|
}
|
||||||
|
// Inventory without following links; curated-unit interpretation remains a runtime check.
|
||||||
|
const pending = [base];
|
||||||
|
let count = 0;
|
||||||
|
while (pending.length) {
|
||||||
|
const current = pending.pop()!;
|
||||||
|
for (const entry of directories(root, current)) {
|
||||||
|
if (++count > 100_000) fail(base, "evidence.source", "inventory_limit", "Reduce the Evidence tree below 100,000 entries before local validation.");
|
||||||
|
const path = `${current}/${entry.name}`;
|
||||||
|
if (entry.isDirectory()) pending.push(path);
|
||||||
|
else {
|
||||||
|
const info = stat(root, path, false);
|
||||||
|
const relative = path.slice(base.length + 1);
|
||||||
|
// Only apply content checks to selections whose meaning is unambiguous locally.
|
||||||
|
// Arbitrary globs are expanded by the canonical Python adapter after startup.
|
||||||
|
const curated = evidence.schema_version === 2 && relative.startsWith("curated/") && relative.endsWith(".md");
|
||||||
|
const selected = curated || literals.includes(relative) || (patterns.includes("**/*.md") && relative.endsWith(".md"));
|
||||||
|
if (selected && info.size > evidence.source.max_bytes) fail(path, "evidence.source.max_bytes", "evidence_too_large", "Reduce the source file or increase the declared max_bytes limit deliberately.");
|
||||||
|
try { closeSync(openSync(join(root, path), "r")); }
|
||||||
|
catch { fail(path, "$", "unreadable", "Grant read access to this Evidence file and retry validation."); }
|
||||||
|
if (curated) {
|
||||||
|
const text = readDocument(root, path);
|
||||||
|
const frontmatter = text.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
||||||
|
if (!frontmatter) fail(path, "$", "evidence_frontmatter", "Add a YAML frontmatter block delimited by --- to the curated Markdown unit; follow the Curated Evidence contract.");
|
||||||
|
decode(frontmatter[1], path, (source) => parseAllDocuments(source)[0].toJSON());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "local-files";
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate(root: string, report: Report): void {
|
||||||
|
directories(root, ".");
|
||||||
|
const catalog = decode(readDocument(root, CATALOG_PATH), CATALOG_PATH, parseWorkspaceCatalogYaml);
|
||||||
|
const ids = new Set(catalog.workspaces.map((entry) => entry.id));
|
||||||
|
for (const entry of directories(root, ".")) {
|
||||||
|
if (entry.name === ".git") continue;
|
||||||
|
if (entry.isSymbolicLink()) fail(".", "$", "unsafe_reference", "Replace repository-root symbolic links with regular files or directories.");
|
||||||
|
if (entry.isDirectory() && entry.name !== "workspace-docs" && !ids.has(entry.name)) {
|
||||||
|
fail(".", "workspaces", "unlisted_directory", "Every root directory except workspace-docs must match a catalog workspace id; remove or register the extra directory.");
|
||||||
|
}
|
||||||
|
if (entry.name === "workspace-docs") {
|
||||||
|
for (const docs of directories(root, "workspace-docs")) {
|
||||||
|
if (!ids.has(docs.name)) fail("workspace-docs", "$", "unlisted_documentation", "Keep documentation only for workspace ids listed in the catalog.");
|
||||||
|
for (const file of directories(root, `workspace-docs/${docs.name}`)) {
|
||||||
|
const path = `workspace-docs/${docs.name}/${file.name}`;
|
||||||
|
if (!["README.md", "contract.env.example"].includes(file.name)) fail(`workspace-docs/${docs.name}`, "$", "unsupported_documentation", "Keep only README.md and contract.env.example in workspace-docs/<id>. Place Evidence inside the workspace directory.");
|
||||||
|
stat(root, path, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const entry of catalog.workspaces) {
|
||||||
|
const document = `${entry.id}/workspace.yaml`;
|
||||||
|
try {
|
||||||
|
stat(root, entry.id, true);
|
||||||
|
const descriptor = decode(readDocument(root, document), document, parseWorkspaceYaml);
|
||||||
|
try { assertCatalogMatchesDescriptor(entry, descriptor); }
|
||||||
|
catch { fail(document, "workspace", "catalog_mismatch", "Make id, name and description identical in the catalog, descriptor and workspace directory name."); }
|
||||||
|
const evidence = inspectEvidence(root, descriptor);
|
||||||
|
report.workspaces.push({ id: entry.id, evidence });
|
||||||
|
if (evidence !== "absent") report.deferred_checks.push(`${entry.id}:evidence-source-selection`, `${entry.id}:evidence-content-provenance-and-indexing`);
|
||||||
|
if (evidence === "remote-deferred") report.deferred_checks.push(`${entry.id}:remote-evidence-access`);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof DocumentError) report.issues.push(error.issue);
|
||||||
|
else throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare(root: string, options: Map<string, string>): void {
|
||||||
|
const id = options.get("--id");
|
||||||
|
const name = options.get("--name");
|
||||||
|
const language = options.get("--language") ?? "en";
|
||||||
|
const catalog = stringify({ schema_version: 1, workspaces: [{ id, name }] });
|
||||||
|
const descriptor = stringify({ workspace: { schema_version: 4, id, name, language } });
|
||||||
|
decode(catalog, CATALOG_PATH, parseWorkspaceCatalogYaml);
|
||||||
|
decode(descriptor, "workspace.yaml", parseWorkspaceYaml);
|
||||||
|
try { mkdirSync(root); }
|
||||||
|
catch (error) {
|
||||||
|
if ((error as NodeJS.ErrnoException).code === "EEXIST") fail(".", "--directory", "destination_exists", "Choose a new directory; preparation never overwrites an existing directory or its documents.");
|
||||||
|
fail(".", "--directory", "destination_unavailable", "Create the parent directory and grant write access, then choose a new destination.");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mkdirSync(join(root, id!));
|
||||||
|
mkdirSync(join(root, "workspace-docs", id!), { recursive: true });
|
||||||
|
writeFileSync(join(root, CATALOG_PATH), "# Index of workspace identities. Keep metadata identical to each descriptor.\n" + catalog, { flag: "wx" });
|
||||||
|
writeFileSync(join(root, id!, "workspace.yaml"), "# Authored workspace v4: optional Evidence; database binding belongs to the Metadata Catalog.\n" + descriptor, { flag: "wx" });
|
||||||
|
writeFileSync(join(root, "workspace-docs", id!, "README.md"),
|
||||||
|
"# Workspace documents / Documenti workspace\n\n" +
|
||||||
|
"EN: Edit thoth-workspaces.yaml and <id>/workspace.yaml together. Evidence is optional and absent by default. Add reviewed source material under <id>/evidence only when configured. Database connections and schema belong to the installation Metadata Catalog. No example databases are downloaded.\n\n" +
|
||||||
|
"IT: Modificare insieme thoth-workspaces.yaml e <id>/workspace.yaml. Le Evidence sono facoltative e inizialmente assenti. Inserire materiale verificato in <id>/evidence solo quando configurato. Connessioni e schema dei database appartengono al Metadata Catalog dell'installazione. Nessun database di esempio viene scaricato.\n\n" +
|
||||||
|
"Repeat / Ripetere: `tht workspace validate --directory <repository>`. Local success does not establish runtime readiness or semantic truth / Il successo locale non certifica readiness o verità semantica.\n", { flag: "wx" });
|
||||||
|
} catch {
|
||||||
|
rmSync(root, { recursive: true, force: true });
|
||||||
|
fail(".", "$", "prepare_failed", "Preparation could not write the documents; check disk space and permissions, then retry with a new directory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function runWorkspaceDocuments(args: string[]): { status: number; output: string } {
|
||||||
|
const report: Report = { schema_version: 1, scope: "local-documents", ok: false, workspaces: [], issues: [], deferred_checks: ["catalog-database-binding", "database-connectivity", "runtime-preprocessing"] };
|
||||||
|
const json = args.includes("--json");
|
||||||
|
let status = 1;
|
||||||
|
try {
|
||||||
|
const [command, ...rest] = args;
|
||||||
|
if ((command === "prepare" || command === "validate") && rest.length === 1 && rest[0] === "--help") return { status: 0, output: usage };
|
||||||
|
const allowed = command === "prepare" ? ["--directory", "--id", "--name", "--language"] : command === "validate" ? ["--directory"] : [];
|
||||||
|
const options = new Map<string, string>();
|
||||||
|
const seen = new Set<string>();
|
||||||
|
for (let index = 0; index < rest.length; index++) {
|
||||||
|
const key = rest[index];
|
||||||
|
if (seen.has(key)) fail("CLI", "$", "usage", usage);
|
||||||
|
seen.add(key);
|
||||||
|
if (key === "--json") continue;
|
||||||
|
if (!allowed.includes(key) || !rest[index + 1] || rest[index + 1].startsWith("--")) fail("CLI", "$", "usage", usage);
|
||||||
|
options.set(key, rest[++index]);
|
||||||
|
}
|
||||||
|
if (!allowed.length || !options.has("--directory") || (command === "prepare" && (!options.has("--id") || !options.has("--name")))) fail("CLI", "$", "usage", usage);
|
||||||
|
const root = resolve(options.get("--directory")!);
|
||||||
|
if (command === "prepare") prepare(root, options);
|
||||||
|
validate(root, report);
|
||||||
|
report.ok = report.issues.length === 0;
|
||||||
|
status = report.ok ? 0 : 1;
|
||||||
|
} catch (error) {
|
||||||
|
report.issues.push(error instanceof DocumentError ? error.issue : { document: ".", field: "$", code: "io_error", correction: "Check local permissions and regular files, then retry; no services were started." });
|
||||||
|
if (report.issues[0].code === "usage") status = 2;
|
||||||
|
}
|
||||||
|
const output = json ? JSON.stringify(report) : [
|
||||||
|
report.ok ? "Workspace documents pass local validation." : "Workspace documents require corrections.",
|
||||||
|
...report.issues.map((issue) => `${issue.document}${issue.line ? `:${issue.line}` : ""} [${issue.field}] ${issue.code}: ${issue.correction}`),
|
||||||
|
...report.workspaces.map((entry) => `${entry.id}: Evidence ${entry.evidence}`),
|
||||||
|
`Deferred until runtime: ${report.deferred_checks.join(", ")}.`,
|
||||||
|
].join("\n");
|
||||||
|
return { status, output };
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { lstatSync, mkdirSync } from "node:fs";
|
|||||||
import { mkdir } from "node:fs/promises";
|
import { mkdir } from "node:fs/promises";
|
||||||
import { isAbsolute, join } from "node:path";
|
import { isAbsolute, join } from "node:path";
|
||||||
import { promisify, TextDecoder } from "node:util";
|
import { promisify, TextDecoder } from "node:util";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
import type { WorkspaceErrorCode, WorkspaceRegistryConfig } from "./types.js";
|
import type { WorkspaceErrorCode, WorkspaceRegistryConfig } from "./types.js";
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
@@ -29,6 +30,13 @@ export interface EvidenceTreeObject {
|
|||||||
posixPath: string;
|
posixPath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PreparedWorkspaceSource {
|
||||||
|
remote: string;
|
||||||
|
branch: string;
|
||||||
|
revision: string;
|
||||||
|
files: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
export class WorkspaceRegistryError extends Error {
|
export class WorkspaceRegistryError extends Error {
|
||||||
constructor(readonly code: WorkspaceErrorCode, message: string) {
|
constructor(readonly code: WorkspaceErrorCode, message: string) {
|
||||||
super(message);
|
super(message);
|
||||||
@@ -187,6 +195,31 @@ export class GitWorkspaceRepository {
|
|||||||
return await this.status();
|
return await this.status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Installation consumes exactly prepared contents; it never resets or retargets a checkout. */
|
||||||
|
async verifyPrepared(expected: PreparedWorkspaceSource): Promise<string> {
|
||||||
|
const mismatch = () => new WorkspaceRegistryError("workspace_stale", "Prepared workspace source differs from the configured repository.");
|
||||||
|
if (!this.config.remoteUrl || expected.branch !== this.config.branch || expected.remote !== this.config.remoteUrl) throw mismatch();
|
||||||
|
await this.ensureLayout();
|
||||||
|
if (isMissing(this.repoPath)) await this.clone();
|
||||||
|
const origin = (await this.git(["remote", "get-url", "origin"])).trim();
|
||||||
|
if (origin !== this.config.remoteUrl) throw mismatch();
|
||||||
|
if ((await this.git(["symbolic-ref", "--short", "HEAD"])).trim() !== expected.branch ||
|
||||||
|
(await this.git(["status", "--porcelain"])).trim()) throw mismatch();
|
||||||
|
const head = (await this.git(["rev-parse", "HEAD"])).trim();
|
||||||
|
if (expected.revision !== "content-snapshot" && expected.revision !== head) throw mismatch();
|
||||||
|
const entries = (await this.git(["ls-tree", "-r", "-z", head])).split("\0").filter(Boolean);
|
||||||
|
if (entries.length !== Object.keys(expected.files).length || entries.length > 10000) throw mismatch();
|
||||||
|
let total = 0;
|
||||||
|
for (const entry of entries) {
|
||||||
|
const match = /^(100644|100755) blob ([a-f0-9]{40})\t(.+)$/s.exec(entry);
|
||||||
|
if (!match || !Object.hasOwn(expected.files, match[3])) throw mismatch();
|
||||||
|
const bytes = await this.gitBlobBytes(match[2], 32 << 20, "prepared");
|
||||||
|
total += bytes.length;
|
||||||
|
if (total > 256 << 20 || createHash("sha256").update(bytes).digest("hex") !== expected.files[match[3]]) throw mismatch();
|
||||||
|
}
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
async pull(): Promise<GitStatus> {
|
async pull(): Promise<GitStatus> {
|
||||||
await this.ensureLayout();
|
await this.ensureLayout();
|
||||||
if (isMissing(this.repoPath)) return await this.bootstrap();
|
if (isMissing(this.repoPath)) return await this.bootstrap();
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { PreprocessingStateError, PreprocessingStateStore } from "./preprocessing-state.js";
|
||||||
|
|
||||||
|
export interface PreprocessingChildGuard {
|
||||||
|
lockPath: string;
|
||||||
|
tokenPath: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The parent lock excludes live orchestrators. Worker locks survive parent death;
|
||||||
|
// rotating the generation under their exclusive lock fences children not yet started.
|
||||||
|
export async function acquirePreprocessingOwner(dataRoot: string, workspaceId: string) {
|
||||||
|
const state = new PreprocessingStateStore({ dataRoot, workspaceId });
|
||||||
|
const owner = await state.acquireWriterLock();
|
||||||
|
try {
|
||||||
|
const workers = await state.acquireWriterLock("workers");
|
||||||
|
try {
|
||||||
|
const token = state.rotateOwnerToken();
|
||||||
|
return { guard: { lockPath: state.workerLockPath(), tokenPath: state.ownerTokenPath(), token }, release: owner.release,
|
||||||
|
assertOwned: () => {
|
||||||
|
if (!owner.isHeld() || readFileSync(state.ownerTokenPath(), "utf8") !== token) throw new PreprocessingStateError("preprocessing_conflict", "Preprocessing ownership was lost");
|
||||||
|
} };
|
||||||
|
} finally { await workers.release(); }
|
||||||
|
} catch (error) { await owner.release(); throw error; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const guardedExec = [
|
||||||
|
"import fcntl, os, sys",
|
||||||
|
"fd = os.open(sys.argv[1], os.O_RDWR | getattr(os, 'O_NOFOLLOW', 0))",
|
||||||
|
"try:",
|
||||||
|
" fcntl.flock(fd, fcntl.LOCK_SH | fcntl.LOCK_NB)",
|
||||||
|
"except BlockingIOError:",
|
||||||
|
" sys.exit(73)",
|
||||||
|
"token_fd = os.open(sys.argv[2], os.O_RDONLY | getattr(os, 'O_NOFOLLOW', 0))",
|
||||||
|
"with os.fdopen(token_fd) as token_file:",
|
||||||
|
" if token_file.read(65) != sys.argv[3]: sys.exit(73)",
|
||||||
|
"os.set_inheritable(fd, True)",
|
||||||
|
"os.execvp(sys.argv[4], sys.argv[4:])",
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
|
export function guardedPreprocessingCommand(guard: PreprocessingChildGuard, executable: string, args: string[]) {
|
||||||
|
return { executable: "python3", args: ["-c", guardedExec, guard.lockPath, guard.tokenPath, guard.token, executable, ...args] };
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
import type { DeterministicRuntimeConfigLease } from "./runtime-config-lease.js";
|
import type { DeterministicRuntimeConfigLease } from "./runtime-config-lease.js";
|
||||||
import { buildCatalogMetadataSnapshot } from "../catalog/metadata-snapshot.js";
|
import { buildCatalogMetadataSnapshot } from "../catalog/metadata-snapshot.js";
|
||||||
import type { CatalogRepository } from "../catalog/types.js";
|
import type { CatalogRepository } from "../catalog/types.js";
|
||||||
|
import { acquirePreprocessingOwner, type PreprocessingChildGuard } from "./preprocessing-owner.js";
|
||||||
|
|
||||||
export interface WorkspaceOperationResult {
|
export interface WorkspaceOperationResult {
|
||||||
schemaVersion: 1;
|
schemaVersion: 1;
|
||||||
@@ -47,6 +48,7 @@ export interface WorkspaceOperationResult {
|
|||||||
export interface ChildProcessRequest {
|
export interface ChildProcessRequest {
|
||||||
argv: string[];
|
argv: string[];
|
||||||
configPath: string;
|
configPath: string;
|
||||||
|
guard?: PreprocessingChildGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ActiveRuntime {
|
interface ActiveRuntime {
|
||||||
@@ -79,6 +81,7 @@ export interface WorkspacePreprocessingServiceDeps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface RunScope {
|
interface RunScope {
|
||||||
|
owner: Awaited<ReturnType<typeof acquirePreprocessingOwner>>;
|
||||||
runtime: ActiveRuntime;
|
runtime: ActiveRuntime;
|
||||||
state: PreprocessingStateStore;
|
state: PreprocessingStateStore;
|
||||||
job: PreprocessingJobState;
|
job: PreprocessingJobState;
|
||||||
@@ -205,13 +208,39 @@ export class WorkspacePreprocessingService {
|
|||||||
const runtime = await this.deps.acquireActiveRuntime(options.workspaceId);
|
const runtime = await this.deps.acquireActiveRuntime(options.workspaceId);
|
||||||
return baseResult(runtime, "preprocess run", "failed", "catalog_not_ready");
|
return baseResult(runtime, "preprocess run", "failed", "catalog_not_ready");
|
||||||
}
|
}
|
||||||
return await this.runFromCatalog(options);
|
const owner = await acquirePreprocessingOwner(this.deps.dataRoot, options.workspaceId);
|
||||||
|
try {
|
||||||
|
const previous = await this.deps.catalogRepository.getByWorkspace(options.workspaceId);
|
||||||
|
// Only runs created under this guard protocol can be reclaimed automatically.
|
||||||
|
const lastJob = this.state(options.workspaceId).readLatestJob();
|
||||||
|
if (previous?.preprocessingStatus === "running" && previous.preprocessingInputFingerprint
|
||||||
|
&& (lastJob?.ownerProtocol !== 1 || !previous.preprocessingRunId || lastJob.runId !== previous.preprocessingRunId)) {
|
||||||
|
const runtime = await this.deps.acquireActiveRuntime(options.workspaceId);
|
||||||
|
return baseResult(runtime, "preprocess run", "failed", "preprocessing_conflict",
|
||||||
|
{ warnings: ["An older preprocessing owner cannot be recovered automatically."] });
|
||||||
|
}
|
||||||
|
if (previous?.preprocessingStatus === "running" && previous.preprocessingInputFingerprint && lastJob?.ownerProtocol === 1) {
|
||||||
|
owner.assertOwned();
|
||||||
|
await this.deps.catalogRepository.finishPreprocessing(options.workspaceId,
|
||||||
|
previous.metadataContentRevision, previous.preprocessingInputFingerprint,
|
||||||
|
{ status: "failed", errorCode: "preprocessing_interrupted" }, previous.preprocessingRunId);
|
||||||
|
}
|
||||||
|
owner.assertOwned();
|
||||||
|
return await this.runFromCatalog(options, owner);
|
||||||
|
} finally { await owner.release(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
async clear(options: { workspaceId: string }): Promise<WorkspaceOperationResult> {
|
async clear(options: { workspaceId: string }): Promise<WorkspaceOperationResult> {
|
||||||
|
const owner = await acquirePreprocessingOwner(this.deps.dataRoot, options.workspaceId);
|
||||||
|
try { return await this.clearOwned(options, owner); }
|
||||||
|
finally { await owner.release(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private async clearOwned(options: { workspaceId: string }, owner: RunScope["owner"]): Promise<WorkspaceOperationResult> {
|
||||||
const runtime = await this.deps.acquireActiveRuntime(options.workspaceId);
|
const runtime = await this.deps.acquireActiveRuntime(options.workspaceId);
|
||||||
const repository = this.deps.catalogRepository;
|
const repository = this.deps.catalogRepository;
|
||||||
if (!repository) return baseResult(runtime, "preprocess clear", "failed", "catalog_not_ready");
|
if (!repository) return baseResult(runtime, "preprocess clear", "failed", "catalog_not_ready");
|
||||||
|
owner.assertOwned();
|
||||||
const cleared = await repository.clearPreprocessing(runtime.workspaceId);
|
const cleared = await repository.clearPreprocessing(runtime.workspaceId);
|
||||||
if (cleared.kind !== "cleared") {
|
if (cleared.kind !== "cleared") {
|
||||||
return baseResult(
|
return baseResult(
|
||||||
@@ -224,7 +253,9 @@ export class WorkspacePreprocessingService {
|
|||||||
const result = await this.deps.runChild({
|
const result = await this.deps.runChild({
|
||||||
argv: ["preprocess", "clear", "--json", "-c", "/dev/fd/3"],
|
argv: ["preprocess", "clear", "--json", "-c", "/dev/fd/3"],
|
||||||
configPath: runtime.configLease.path,
|
configPath: runtime.configLease.path,
|
||||||
|
guard: owner.guard,
|
||||||
});
|
});
|
||||||
|
owner.assertOwned();
|
||||||
if (result.exitCode !== 0) {
|
if (result.exitCode !== 0) {
|
||||||
return baseResult(runtime, "preprocess clear", "failed", "preprocessing_clear_failed");
|
return baseResult(runtime, "preprocess clear", "failed", "preprocessing_clear_failed");
|
||||||
}
|
}
|
||||||
@@ -234,11 +265,13 @@ export class WorkspacePreprocessingService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runFromCatalog(options: { workspaceId: string }): Promise<WorkspaceOperationResult> {
|
private async runFromCatalog(options: { workspaceId: string }, owner: RunScope["owner"]): Promise<WorkspaceOperationResult> {
|
||||||
const scope = await this.startRun(options.workspaceId);
|
const scope = await this.startRun(options.workspaceId, owner);
|
||||||
const repository = this.deps.catalogRepository!;
|
const repository = this.deps.catalogRepository!;
|
||||||
const fingerprint = scope.runtime.configLease.inputFingerprint;
|
const fingerprint = scope.runtime.configLease.inputFingerprint;
|
||||||
const started = await repository.beginPreprocessing(scope.runtime.workspaceId, fingerprint);
|
owner.assertOwned();
|
||||||
|
const started = await repository.beginPreprocessing(scope.runtime.workspaceId, fingerprint, scope.job.runId);
|
||||||
|
owner.assertOwned();
|
||||||
if (started.kind !== "started") {
|
if (started.kind !== "started") {
|
||||||
scope.job.status = "failed";
|
scope.job.status = "failed";
|
||||||
scope.state.writeJob(scope.job);
|
scope.state.writeJob(scope.job);
|
||||||
@@ -260,19 +293,23 @@ export class WorkspacePreprocessingService {
|
|||||||
scope.runtime.workspaceId,
|
scope.runtime.workspaceId,
|
||||||
revision,
|
revision,
|
||||||
);
|
);
|
||||||
|
owner.assertOwned();
|
||||||
const snapshotPath = this.publishCatalogSnapshot(
|
const snapshotPath = this.publishCatalogSnapshot(
|
||||||
scope.runtime.workspaceId,
|
scope.runtime.workspaceId,
|
||||||
JSON.stringify(snapshot),
|
JSON.stringify(snapshot),
|
||||||
);
|
);
|
||||||
this.completeStages(scope, "catalog_snapshot");
|
this.completeStages(scope, "catalog_snapshot");
|
||||||
const semantic = await this.deps.semanticPreflight(scope.runtime.workspace);
|
const semantic = await this.deps.semanticPreflight(scope.runtime.workspace);
|
||||||
|
owner.assertOwned();
|
||||||
if (!semantic.ok) {
|
if (!semantic.ok) {
|
||||||
await repository.finishPreprocessing(
|
await repository.finishPreprocessing(
|
||||||
scope.runtime.workspaceId,
|
scope.runtime.workspaceId,
|
||||||
revision,
|
revision,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
{ status: "failed", errorCode: semantic.code },
|
{ status: "failed", errorCode: semantic.code },
|
||||||
|
scope.job.runId,
|
||||||
);
|
);
|
||||||
|
owner.assertOwned();
|
||||||
scope.job.status = "failed";
|
scope.job.status = "failed";
|
||||||
scope.state.writeJob(scope.job);
|
scope.state.writeJob(scope.job);
|
||||||
finished = true;
|
finished = true;
|
||||||
@@ -280,7 +317,7 @@ export class WorkspacePreprocessingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
failureCode = "schema_index_failed";
|
failureCode = "schema_index_failed";
|
||||||
const payload = await this.runJsonStage(scope.runtime, [
|
const payload = await this.runJsonStage(scope, [
|
||||||
"preprocess",
|
"preprocess",
|
||||||
"catalog",
|
"catalog",
|
||||||
"--catalog-metadata",
|
"--catalog-metadata",
|
||||||
@@ -301,12 +338,15 @@ export class WorkspacePreprocessingService {
|
|||||||
this.evidenceDependencies(scope),
|
this.evidenceDependencies(scope),
|
||||||
);
|
);
|
||||||
if (!["succeeded", "unchanged"].includes(outcome.status)) {
|
if (!["succeeded", "unchanged"].includes(outcome.status)) {
|
||||||
|
owner.assertOwned();
|
||||||
await repository.finishPreprocessing(
|
await repository.finishPreprocessing(
|
||||||
scope.runtime.workspaceId,
|
scope.runtime.workspaceId,
|
||||||
revision,
|
revision,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
{ status: "failed", errorCode: outcome.code },
|
{ status: "failed", errorCode: outcome.code },
|
||||||
|
scope.job.runId,
|
||||||
);
|
);
|
||||||
|
owner.assertOwned();
|
||||||
scope.job.status = "failed";
|
scope.job.status = "failed";
|
||||||
scope.state.writeJob(scope.job);
|
scope.state.writeJob(scope.job);
|
||||||
finished = true;
|
finished = true;
|
||||||
@@ -319,29 +359,35 @@ export class WorkspacePreprocessingService {
|
|||||||
revision,
|
revision,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
{ status: "succeeded" },
|
{ status: "succeeded" },
|
||||||
|
scope.job.runId,
|
||||||
);
|
);
|
||||||
|
owner.assertOwned();
|
||||||
if (!completed) throw new Error("catalog preprocessing completion lost its lease");
|
if (!completed) throw new Error("catalog preprocessing completion lost its lease");
|
||||||
scope.job.status = "succeeded";
|
scope.job.status = "succeeded";
|
||||||
scope.state.writeJob(scope.job);
|
scope.state.writeJob(scope.job);
|
||||||
finished = true;
|
finished = true;
|
||||||
return this.evidenceResult(scope, outcome);
|
return this.evidenceResult(scope, outcome);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
owner.assertOwned();
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
await repository.finishPreprocessing(
|
await repository.finishPreprocessing(
|
||||||
scope.runtime.workspaceId,
|
scope.runtime.workspaceId,
|
||||||
revision,
|
revision,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
{ status: "failed", errorCode: failureCode },
|
{ status: "failed", errorCode: failureCode },
|
||||||
|
scope.job.runId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
owner.assertOwned();
|
||||||
scope.job.status = "failed";
|
scope.job.status = "failed";
|
||||||
scope.state.writeJob(scope.job);
|
scope.state.writeJob(scope.job);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async startRun(workspaceId: string): Promise<RunScope> {
|
private async startRun(workspaceId: string, owner: RunScope["owner"]): Promise<RunScope> {
|
||||||
const runtime = await this.deps.acquireActiveRuntime(workspaceId);
|
const runtime = await this.deps.acquireActiveRuntime(workspaceId);
|
||||||
|
owner.assertOwned();
|
||||||
const state = this.state(runtime.workspaceId);
|
const state = this.state(runtime.workspaceId);
|
||||||
const job = await state.beginJob({
|
const job = await state.beginJob({
|
||||||
operation: "preprocess run",
|
operation: "preprocess run",
|
||||||
@@ -353,7 +399,10 @@ export class WorkspacePreprocessingService {
|
|||||||
embeddingId: runtime.configLease.effectiveConfig.embedding.id,
|
embeddingId: runtime.configLease.effectiveConfig.embedding.id,
|
||||||
embeddingDimensions: runtime.configLease.effectiveConfig.embedding.dimensions,
|
embeddingDimensions: runtime.configLease.effectiveConfig.embedding.dimensions,
|
||||||
});
|
});
|
||||||
return { runtime, state, job };
|
owner.assertOwned();
|
||||||
|
job.ownerProtocol = 1;
|
||||||
|
state.writeJob(job);
|
||||||
|
return { runtime, state, job, owner };
|
||||||
}
|
}
|
||||||
|
|
||||||
private state(workspaceId: string): PreprocessingStateStore {
|
private state(workspaceId: string): PreprocessingStateStore {
|
||||||
@@ -361,6 +410,7 @@ export class WorkspacePreprocessingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private completeStages(scope: RunScope, ...stages: string[]): void {
|
private completeStages(scope: RunScope, ...stages: string[]): void {
|
||||||
|
scope.owner.assertOwned();
|
||||||
for (const stage of stages) {
|
for (const stage of stages) {
|
||||||
if (!scope.job.completedStages.includes(stage)) scope.job.completedStages.push(stage);
|
if (!scope.job.completedStages.includes(stage)) scope.job.completedStages.push(stage);
|
||||||
}
|
}
|
||||||
@@ -384,8 +434,8 @@ export class WorkspacePreprocessingService {
|
|||||||
|
|
||||||
private evidenceDependencies(scope: RunScope): EvidencePreprocessingDependencies {
|
private evidenceDependencies(scope: RunScope): EvidencePreprocessingDependencies {
|
||||||
return {
|
return {
|
||||||
runStage: async (argv) => await this.runJsonStage(scope.runtime, argv),
|
runStage: async (argv) => await this.runJsonStage(scope, argv),
|
||||||
persistJob: () => this.state(scope.runtime.workspaceId).writeJob(scope.job),
|
persistJob: () => { scope.owner.assertOwned(); this.state(scope.runtime.workspaceId).writeJob(scope.job); },
|
||||||
evidencePreflight: async () => await this.deps.evidencePreflight(scope.runtime.workspace),
|
evidencePreflight: async () => await this.deps.evidencePreflight(scope.runtime.workspace),
|
||||||
requireRunId: (value) => this.requireRunId(value),
|
requireRunId: (value) => this.requireRunId(value),
|
||||||
numberRecord: (value) => this.numberRecord(value),
|
numberRecord: (value) => this.numberRecord(value),
|
||||||
@@ -400,8 +450,10 @@ export class WorkspacePreprocessingService {
|
|||||||
return baseResult(scope.runtime, "preprocess run", status, code, extra);
|
return baseResult(scope.runtime, "preprocess run", status, code, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runJsonStage(runtime: ActiveRuntime, argv: string[]): Promise<Record<string, unknown>> {
|
private async runJsonStage(scope: RunScope, argv: string[]): Promise<Record<string, unknown>> {
|
||||||
const result = await this.deps.runChild({ argv, configPath: runtime.configLease.path });
|
scope.owner.assertOwned();
|
||||||
|
const result = await this.deps.runChild({ argv, configPath: scope.runtime.configLease.path, guard: scope.owner.guard });
|
||||||
|
scope.owner.assertOwned();
|
||||||
if (result.exitCode !== 0) throw new Error("workspace child failed");
|
if (result.exitCode !== 0) throw new Error("workspace child failed");
|
||||||
return JSON.parse(result.stdout) as Record<string, unknown>;
|
return JSON.parse(result.stdout) as Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export interface SessionInventoryRow {
|
|||||||
|
|
||||||
export interface WriterLockLease {
|
export interface WriterLockLease {
|
||||||
holderPid: number;
|
holderPid: number;
|
||||||
|
isHeld(): boolean;
|
||||||
release(): Promise<void>;
|
release(): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ export interface PreprocessingJobState {
|
|||||||
status: "active" | "succeeded" | "blocked" | "failed";
|
status: "active" | "succeeded" | "blocked" | "failed";
|
||||||
candidateDigest?: string;
|
candidateDigest?: string;
|
||||||
reviewDigest?: string;
|
reviewDigest?: string;
|
||||||
|
ownerProtocol?: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FkReviewRecord {
|
export interface FkReviewRecord {
|
||||||
@@ -195,6 +197,14 @@ export class PreprocessingStateStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writerLockPath(): string { return join(this.root, "writer.lock"); }
|
writerLockPath(): string { return join(this.root, "writer.lock"); }
|
||||||
|
workerLockPath(): string { return join(this.root, "workers.lock"); }
|
||||||
|
ownerTokenPath(): string { return join(this.root, "owner-token"); }
|
||||||
|
rotateOwnerToken(): string {
|
||||||
|
this.ensureLayout();
|
||||||
|
const token = randomBytes(32).toString("hex");
|
||||||
|
writeAtomicFile(this.ownerTokenPath(), token, 0o600);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
runtimeConfigDirectory(): string { return join(this.root, "runtime-config"); }
|
runtimeConfigDirectory(): string { return join(this.root, "runtime-config"); }
|
||||||
runtimeConfigManifestDirectory(): string { return join(this.root, "runtime-config-manifests"); }
|
runtimeConfigManifestDirectory(): string { return join(this.root, "runtime-config-manifests"); }
|
||||||
jobsDirectory(): string { return join(this.root, "jobs"); }
|
jobsDirectory(): string { return join(this.root, "jobs"); }
|
||||||
@@ -216,9 +226,9 @@ export class PreprocessingStateStore {
|
|||||||
]) ensureDirectory(directory);
|
]) ensureDirectory(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async acquireWriterLock(): Promise<WriterLockLease> {
|
async acquireWriterLock(kind: "writer" | "workers" = "writer"): Promise<WriterLockLease> {
|
||||||
this.ensureLayout();
|
this.ensureLayout();
|
||||||
const lockPath = this.writerLockPath();
|
const lockPath = kind === "writer" ? this.writerLockPath() : this.workerLockPath();
|
||||||
try {
|
try {
|
||||||
const entry = lstatSync(lockPath);
|
const entry = lstatSync(lockPath);
|
||||||
if (!entry.isFile() || entry.isSymbolicLink()) throw new Error("invalid writer lock path");
|
if (!entry.isFile() || entry.isSymbolicLink()) throw new Error("invalid writer lock path");
|
||||||
@@ -257,11 +267,14 @@ export class PreprocessingStateStore {
|
|||||||
let released = false;
|
let released = false;
|
||||||
return {
|
return {
|
||||||
holderPid: holder.pid ?? 0,
|
holderPid: holder.pid ?? 0,
|
||||||
|
isHeld: () => !released && holder.exitCode === null && holder.signalCode === null,
|
||||||
release: async () => {
|
release: async () => {
|
||||||
if (released) return;
|
if (released) return;
|
||||||
released = true;
|
released = true;
|
||||||
|
if (holder.exitCode !== null || holder.signalCode !== null) return;
|
||||||
|
const exited = new Promise<void>((resolve) => holder.once("exit", () => resolve()));
|
||||||
if (!holder.stdin.destroyed) holder.stdin.end();
|
if (!holder.stdin.destroyed) holder.stdin.end();
|
||||||
await new Promise<void>((resolve) => holder.once("exit", () => resolve()));
|
await exited;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
WorkspaceRepositoryLock,
|
WorkspaceRepositoryLock,
|
||||||
normalizeRepositoryIdentity,
|
normalizeRepositoryIdentity,
|
||||||
type GitStatus,
|
type GitStatus,
|
||||||
|
type PreparedWorkspaceSource,
|
||||||
} from "./git-repository.js";
|
} from "./git-repository.js";
|
||||||
import {
|
import {
|
||||||
parseWorkspaceYaml,
|
parseWorkspaceYaml,
|
||||||
@@ -121,6 +122,19 @@ export class WorkspaceRegistry {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async prepareInstallation(expected: PreparedWorkspaceSource): Promise<{ revision: string }> {
|
||||||
|
await this.repository.ensureLayout();
|
||||||
|
return await this.lock.run(async () => {
|
||||||
|
const head = await this.repository.verifyPrepared(expected);
|
||||||
|
const active = await this.tryActiveState();
|
||||||
|
if (active && active.head !== head) {
|
||||||
|
throw new WorkspaceRegistryError("workspace_stale", "Reconcile the active workspace revision before installation.");
|
||||||
|
}
|
||||||
|
if (!active) await this.activate(head);
|
||||||
|
return { revision: head };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async pull(): Promise<GitStatus> {
|
async pull(): Promise<GitStatus> {
|
||||||
await this.repository.ensureLayout();
|
await this.repository.ensureLayout();
|
||||||
return await this.lock.run(async () => {
|
return await this.lock.run(async () => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
rmSync,
|
rmSync,
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
} from "node:fs";
|
} from "node:fs";
|
||||||
import { createCipheriv, createDecipheriv, createHash, randomBytes } from "node:crypto";
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
||||||
import { basename, join } from "node:path";
|
import { basename, join } from "node:path";
|
||||||
|
|
||||||
const STORE_ERROR = "Workspace secret store is unavailable.";
|
const STORE_ERROR = "Workspace secret store is unavailable.";
|
||||||
@@ -122,6 +122,21 @@ export class WorkspaceSecretStore {
|
|||||||
return this.readVault().entries[entryKey(workspaceId, requirementId)] !== undefined;
|
return this.readVault().entries[entryKey(workspaceId, requirementId)] !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compare without exposing plaintext or a reusable digest to an API consumer. */
|
||||||
|
matches(workspaceId: string, requirementId: string, value: string): boolean {
|
||||||
|
const materialized = this.materialize(workspaceId, [requirementId]);
|
||||||
|
let current: Buffer | undefined;
|
||||||
|
const expected = Buffer.from(value, "utf8");
|
||||||
|
try {
|
||||||
|
const path = materialized.files.get(requirementId);
|
||||||
|
if (!path) return false;
|
||||||
|
current = readFileSync(path);
|
||||||
|
return current.length === expected.length && timingSafeEqual(current, expected);
|
||||||
|
} finally {
|
||||||
|
current?.fill(0); expected.fill(0); materialized.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
generation(workspaceId: string): number {
|
generation(workspaceId: string): number {
|
||||||
assertIdentifier(workspaceId, "workspace identifier");
|
assertIdentifier(workspaceId, "workspace identifier");
|
||||||
const vault = this.readVault();
|
const vault = this.readVault();
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { expect, test } from "vitest";
|
||||||
|
import { MemoryCatalogRepository } from "../src/catalog/memory-repository.js";
|
||||||
|
|
||||||
|
test("the in-memory Catalog enforces the same attempt identity as PostgreSQL", async () => {
|
||||||
|
const repository = new MemoryCatalogRepository();
|
||||||
|
const database = await repository.create({ workspaceId: "retry", engine: "postgres",
|
||||||
|
databaseName: "warehouse", schema: "public",
|
||||||
|
binding: { transport: "postgres_direct", host: "db", port: 5432, username: "reader" } });
|
||||||
|
await repository.applySchemaSync(database.id, database.version, "all", [], {
|
||||||
|
schemaVersion: 1, capabilities: { tables: "available", columns: "available", relationships: "available" },
|
||||||
|
tables: [], columns: [], relationships: [],
|
||||||
|
});
|
||||||
|
const revision = (await repository.get(database.id))!.metadataContentRevision;
|
||||||
|
const fingerprint = "sha256:" + "1".repeat(64);
|
||||||
|
await repository.beginPreprocessing("retry", fingerprint, "old");
|
||||||
|
await repository.finishPreprocessing("retry", revision, fingerprint,
|
||||||
|
{ status: "failed", errorCode: "preprocessing_interrupted" }, "old");
|
||||||
|
await repository.beginPreprocessing("retry", fingerprint, "replacement");
|
||||||
|
expect(await repository.finishPreprocessing("retry", revision, fingerprint, { status: "succeeded" }, "old")).toBeUndefined();
|
||||||
|
expect(await repository.finishPreprocessing("retry", revision, fingerprint, { status: "succeeded" }, "replacement"))
|
||||||
|
.toMatchObject({ preprocessingStatus: "succeeded" });
|
||||||
|
});
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import { spawnSync } from "node:child_process";
|
import { spawnSync } from "node:child_process";
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
|
import { mkdtempSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
import { PostgreSqlContainer } from "@testcontainers/postgresql";
|
import { PostgreSqlContainer } from "@testcontainers/postgresql";
|
||||||
import { CamelCasePlugin, Kysely, PostgresDialect, sql } from "kysely";
|
import { CamelCasePlugin, Kysely, PostgresDialect, sql } from "kysely";
|
||||||
import { Pool } from "pg";
|
import { Pool } from "pg";
|
||||||
@@ -19,6 +22,13 @@ import { up as upCanonicalModelIds } from "../src/catalog/migrations/010_canonic
|
|||||||
import { up as upLocalSensitivityAnalysis } from "../src/catalog/migrations/011_local_sensitivity_analysis.js";
|
import { up as upLocalSensitivityAnalysis } from "../src/catalog/migrations/011_local_sensitivity_analysis.js";
|
||||||
import { up as upSensitivityReason } from "../src/catalog/migrations/012_sensitivity_reason.js";
|
import { up as upSensitivityReason } from "../src/catalog/migrations/012_sensitivity_reason.js";
|
||||||
import { up as upCatalogPreprocessingState } from "../src/catalog/migrations/013_catalog_preprocessing_state.js";
|
import { up as upCatalogPreprocessingState } from "../src/catalog/migrations/013_catalog_preprocessing_state.js";
|
||||||
|
import { up as upInstallationBindingImports } from "../src/catalog/migrations/014_installation_binding_imports.js";
|
||||||
|
import { up as upPreprocessingRunIdentity } from "../src/catalog/migrations/015_preprocessing_run_identity.js";
|
||||||
|
import { InstallationBindings } from "../src/catalog/installation-bindings.js";
|
||||||
|
import { CatalogService } from "../src/catalog/service.js";
|
||||||
|
import { CatalogOperationCoordinator } from "../src/catalog/operation-coordinator.js";
|
||||||
|
import { WorkspaceSecretStore } from "../src/workspaces/secret-store.js";
|
||||||
|
import type { WorkspaceRegistry } from "../src/workspaces/registry.js";
|
||||||
|
|
||||||
const dockerAvailable = spawnSync("docker", ["info"], { stdio: "ignore" }).status === 0;
|
const dockerAvailable = spawnSync("docker", ["info"], { stdio: "ignore" }).status === 0;
|
||||||
|
|
||||||
@@ -60,6 +70,8 @@ test.skipIf(!dockerAvailable)("PostgreSQL migration enforces one database per wo
|
|||||||
await upLocalSensitivityAnalysis(db);
|
await upLocalSensitivityAnalysis(db);
|
||||||
await upSensitivityReason(db);
|
await upSensitivityReason(db);
|
||||||
await upCatalogPreprocessingState(db);
|
await upCatalogPreprocessingState(db);
|
||||||
|
await upInstallationBindingImports(db);
|
||||||
|
await upPreprocessingRunIdentity(db);
|
||||||
await expect(db.selectFrom("sensitiveDataSuggestionRuns")
|
await expect(db.selectFrom("sensitiveDataSuggestionRuns")
|
||||||
.select(["engine", "modelId", "policyVersion", "unknown"])
|
.select(["engine", "modelId", "policyVersion", "unknown"])
|
||||||
.where("id", "=", historicalSuggestionRunId)
|
.where("id", "=", historicalSuggestionRunId)
|
||||||
@@ -302,6 +314,16 @@ test.skipIf(!dockerAvailable)("PostgreSQL migration enforces one database per wo
|
|||||||
preprocessingStatus: "succeeded",
|
preprocessingStatus: "succeeded",
|
||||||
preprocessedMetadataRevision: beforePreprocessing.metadataContentRevision,
|
preprocessedMetadataRevision: beforePreprocessing.metadataContentRevision,
|
||||||
});
|
});
|
||||||
|
const fingerprint = "sha256:" + "1".repeat(64);
|
||||||
|
await repository.beginPreprocessing("preprocessing-lock", fingerprint, "old-run");
|
||||||
|
await repository.finishPreprocessing("preprocessing-lock", beforePreprocessing.metadataContentRevision,
|
||||||
|
fingerprint, { status: "failed", errorCode: "preprocessing_interrupted" }, "old-run");
|
||||||
|
await repository.beginPreprocessing("preprocessing-lock", fingerprint, "replacement-run");
|
||||||
|
// Identical inputs must not let a late completion finish the replacement run.
|
||||||
|
await expect(repository.finishPreprocessing("preprocessing-lock", beforePreprocessing.metadataContentRevision,
|
||||||
|
fingerprint, { status: "failed", errorCode: "late-owner" }, "old-run")).resolves.toBeUndefined();
|
||||||
|
await expect(repository.finishPreprocessing("preprocessing-lock", beforePreprocessing.metadataContentRevision,
|
||||||
|
fingerprint, { status: "succeeded" }, "replacement-run")).resolves.toMatchObject({ preprocessingStatus: "succeeded" });
|
||||||
await db.insertInto("catalogTables").values({
|
await db.insertInto("catalogTables").values({
|
||||||
id: randomUUID(),
|
id: randomUUID(),
|
||||||
databaseId: lockedDatabase.id,
|
databaseId: lockedDatabase.id,
|
||||||
@@ -319,6 +341,37 @@ test.skipIf(!dockerAvailable)("PostgreSQL migration enforces one database per wo
|
|||||||
expect(await repository.delete(created.id, 2)).toBe(true);
|
expect(await repository.delete(created.id, 2)).toBe(true);
|
||||||
expect(await repository.list()).toEqual([]);
|
expect(await repository.list()).toEqual([]);
|
||||||
expect(await repository.listTables(created.id)).toEqual([]);
|
expect(await repository.listTables(created.id)).toEqual([]);
|
||||||
|
// Installation import uses the real transactional Catalog and a read-only PostgreSQL login.
|
||||||
|
await sql`CREATE ROLE installation_reader LOGIN PASSWORD 'installation-test-password'`.execute(db);
|
||||||
|
await sql`GRANT USAGE ON SCHEMA public TO installation_reader`.execute(db);
|
||||||
|
const secretRoot = mkdtempSync(join(tmpdir(), "catalog-installation-"));
|
||||||
|
try {
|
||||||
|
const secrets = new WorkspaceSecretStore({ root: secretRoot, installationId: "integration" });
|
||||||
|
const revision = "a".repeat(40);
|
||||||
|
const registry = { read: async () => ({ workspace: { workspace: { schema_version: 4, id: "installation-test", name: "Test", language: "en" } },
|
||||||
|
revision: { commit: revision } }) } as unknown as WorkspaceRegistry;
|
||||||
|
const operations = new CatalogOperationCoordinator();
|
||||||
|
const service = new CatalogService(repository, registry, secrets, [], 5000, undefined, operations);
|
||||||
|
const importer = new InstallationBindings(repository, service, registry, secrets, operations, "integration");
|
||||||
|
const request = { schemaVersion: 1, revision, configuration: {
|
||||||
|
workspaceId: "installation-test", engine: "postgres", databaseName: container.getDatabase(), schema: "public",
|
||||||
|
binding: { transport: "postgres_direct", host: container.getHost(), port: container.getPort(), username: "installation_reader" },
|
||||||
|
}, secrets: { password: "installation-test-password" }, evidenceSecrets: {} };
|
||||||
|
const applied = await importer.apply(request);
|
||||||
|
expect(applied).toMatchObject({ status: "applied", connectionStatus: "reachable", version: 2 });
|
||||||
|
const generation = secrets.generation("installation-test");
|
||||||
|
expect(await importer.apply(request)).toEqual({ ...applied, status: "unchanged" });
|
||||||
|
expect(secrets.generation("installation-test")).toBe(generation);
|
||||||
|
expect(await repository.update(applied.databaseId, 1, request.configuration as never)).toBeUndefined();
|
||||||
|
await repository.touch(applied.databaseId, applied.version);
|
||||||
|
secrets.put("installation-test", "catalog.dwh.password", "administrative-change");
|
||||||
|
await expect(importer.apply(request)).rejects.toThrow("Reconcile");
|
||||||
|
expect(secrets.matches("installation-test", "catalog.dwh.password", "administrative-change")).toBe(true);
|
||||||
|
const currentImport = (await repository.get(applied.databaseId))!;
|
||||||
|
expect(await repository.delete(applied.databaseId, currentImport.version)).toBe(true);
|
||||||
|
await expect(importer.apply(request)).rejects.toThrow("Workspace database already exists");
|
||||||
|
expect(await repository.getByWorkspace("installation-test")).toBeUndefined();
|
||||||
|
} finally { rmSync(secretRoot, { recursive: true, force: true }); }
|
||||||
} finally {
|
} finally {
|
||||||
await db.destroy();
|
await db.destroy();
|
||||||
await container.stop();
|
await container.stop();
|
||||||
|
|||||||
@@ -15,10 +15,34 @@ import {
|
|||||||
import { WorkspaceSecretStore } from "../src/workspaces/secret-store.js";
|
import { WorkspaceSecretStore } from "../src/workspaces/secret-store.js";
|
||||||
import type { WorkspaceRegistry, WorkspaceRevision } from "../src/workspaces/registry.js";
|
import type { WorkspaceRegistry, WorkspaceRevision } from "../src/workspaces/registry.js";
|
||||||
import type { WorkspaceDescriptor } from "../src/workspaces/schema.js";
|
import type { WorkspaceDescriptor } from "../src/workspaces/schema.js";
|
||||||
|
// @ts-expect-error The native operator embeds this plain ESM client.
|
||||||
|
import { prepareWorkspace } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||||
|
|
||||||
const roots: string[] = [];
|
const roots: string[] = [];
|
||||||
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||||
|
|
||||||
|
test("installation retry preserves the durable destructive review and source comments", async () => {
|
||||||
|
const { app, repository, database, setObserved } = await setup();
|
||||||
|
try {
|
||||||
|
await seedCatalog(repository, database);
|
||||||
|
const tablesBefore = await repository.listTables(database.id);
|
||||||
|
setObserved({ schemaVersion: 1, capabilities: { tables: "available", columns: "available", relationships: "available" }, tables: [], columns: [], relationships: [] });
|
||||||
|
const started = await app.inject({ method: "POST", url: `/catalog/databases/${database.id}/sync-runs`, payload: { version: database.version, scope: "all", tableIds: [] } });
|
||||||
|
const run = await waitFor(repository, started.json().id, "awaiting_confirmation");
|
||||||
|
const request = async (path: string, body?: unknown) => {
|
||||||
|
expect(body).toBeUndefined();
|
||||||
|
const response = await app.inject({ method: "GET", url: path });
|
||||||
|
return new Response(response.body, { status: response.statusCode, headers: { "content-type": "application/json" } });
|
||||||
|
};
|
||||||
|
for (let attempt = 0; attempt < 2; attempt++) {
|
||||||
|
await expect(prepareWorkspace(request, "psd-clinical", revision.commit)).rejects.toMatchObject({ code: "schema_review_required", runId: run.id });
|
||||||
|
}
|
||||||
|
expect(await repository.listTables(database.id)).toEqual(tablesBefore);
|
||||||
|
expect(await repository.listSyncRuns(database.id)).toHaveLength(1);
|
||||||
|
expect((await repository.getSyncRun(run.id))?.state).toBe("awaiting_confirmation");
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
const workspace: WorkspaceDescriptor = {
|
const workspace: WorkspaceDescriptor = {
|
||||||
workspace: { schema_version: 4, id: "psd-clinical", name: "Policlinico San Donato", language: "it" },
|
workspace: { schema_version: 4, id: "psd-clinical", name: "Policlinico San Donato", language: "it" },
|
||||||
dwh: { engine: "postgres", database: "warehouse", schema: "datawarehouse", port: 5432, supported_transports: ["postgres_direct"] },
|
dwh: { engine: "postgres", database: "warehouse", schema: "datawarehouse", port: 5432, supported_transports: ["postgres_direct"] },
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { afterEach, expect, test } from "vitest";
|
||||||
|
import { validateDatabaseBootstrap } from "../src/catalog/bootstrap-documents.js";
|
||||||
|
import { runBootstrapValidation } from "../src/catalog/bootstrap-cli.js";
|
||||||
|
|
||||||
|
const roots: string[] = [];
|
||||||
|
afterEach(() => roots.splice(0).forEach((root) => rmSync(root, { recursive: true, force: true })));
|
||||||
|
function fixture() {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), "bootstrap-documents-")); roots.push(root);
|
||||||
|
mkdirSync(join(root, "practice"));
|
||||||
|
writeFileSync(join(root, "thoth-workspaces.yaml"), "schema_version: 1\nworkspaces: [{id: practice, name: Practice}]\n");
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), "workspace: {schema_version: 4, id: practice, name: Practice, language: en}\n");
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
const entry = { workspaceId: "practice", engine: "postgres", databaseName: "practice", schema: "public", binding: { transport: "postgres_direct", host: "db.internal", port: 5432, username: "reader" }, secretFiles: { password: "/private/operator/db-password" } };
|
||||||
|
|
||||||
|
test("bootstrap reuses Catalog configuration and requires one complete binding per workspace", () => {
|
||||||
|
const root = fixture();
|
||||||
|
const valid = validateDatabaseBootstrap({ schemaVersion: 1, databases: [entry] }, root);
|
||||||
|
expect(valid.secretFiles).toContainEqual({ field: "databases.0.secretFiles.password", path: "/private/operator/db-password" });
|
||||||
|
for (const databases of [[], [entry, entry], [{ ...entry, workspaceId: "unknown" }], [{ ...entry, secretFiles: {} }], [{ ...entry, engine: "mysql" }], [{ ...entry, binding: { ...entry.binding, port: 70000 } }]]) {
|
||||||
|
expect(() => validateDatabaseBootstrap({ schemaVersion: 1, databases }, root)).toThrow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("REST authentication, SSH credentials and optional Evidence use their declared contracts", () => {
|
||||||
|
const root = fixture();
|
||||||
|
const rest = { ...entry, binding: { transport: "rest_api", baseUrl: "https://data.internal", restPath: "/query", restAuth: "none" }, secretFiles: {} };
|
||||||
|
expect(validateDatabaseBootstrap({ schemaVersion: 1, databases: [rest] }, root).secretFiles).toEqual([]);
|
||||||
|
expect(() => validateDatabaseBootstrap({ schemaVersion: 1, databases: [{ ...rest, binding: { ...rest.binding, restAuth: "bearer" } }] }, root)).toThrow();
|
||||||
|
const ssh = { ...entry, binding: { transport: "ssh_tunnel", username: "reader", sshHost: "bastion", sshPort: 22, sshUsername: "tunnel", sshTargetHost: "database", sshTargetPort: 5432 }, secretFiles: { password: "/password", sshPrivateKey: "/key", sshKnownHosts: "/hosts" } };
|
||||||
|
expect(validateDatabaseBootstrap({ schemaVersion: 1, databases: [ssh] }, root).warnings[0]).toContain("not NL-to-SQL");
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), "workspace: {schema_version: 4, id: practice, name: Practice, language: en}\nevidence:\n source:\n type: http\n uris: [https://docs.internal/manual.md]\n authentication: signed_urls_file\n");
|
||||||
|
expect(() => validateDatabaseBootstrap({ schemaVersion: 1, databases: [entry] }, root)).toThrow();
|
||||||
|
expect(validateDatabaseBootstrap({ schemaVersion: 1, databases: [{ ...entry, evidenceSecretFiles: { "evidence.signed_urls": "/urls.json" } }] }, root).secretFiles).toContainEqual({ field: "databases.0.evidenceSecretFiles.evidence.signed_urls", path: "/urls.json" });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("bootstrap CLI never echoes arbitrary keys from submitted secret references", () => {
|
||||||
|
const root = fixture();
|
||||||
|
const path = join(root, "bootstrap.yaml");
|
||||||
|
for (const field of ["secretFiles", "evidenceSecretFiles"]) {
|
||||||
|
writeFileSync(path, JSON.stringify({ schemaVersion: 1, databases: [{ ...entry, [field]: { PRIVATE_CREDENTIAL_SENTINEL: "/path" } }] }));
|
||||||
|
const result = runBootstrapValidation(["--directory", root, "--bootstrap", path, "--json"]);
|
||||||
|
expect(result.status).toBe(1);
|
||||||
|
expect(result.output).not.toContain("PRIVATE_CREDENTIAL_SENTINEL");
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
import { mkdtempSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { spawn } from "node:child_process";
|
||||||
|
import { createLocalAuthFixture, localPassword } from "./auth-test-fixtures.js";
|
||||||
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
|
import { buildApp } from "../src/app.js";
|
||||||
|
import { loadConfig } from "../src/config.js";
|
||||||
|
import { MemoryCatalogRepository } from "../src/catalog/memory-repository.js";
|
||||||
|
import { WorkspaceSecretStore } from "../src/workspaces/secret-store.js";
|
||||||
|
import type { WorkspaceRegistry } from "../src/workspaces/registry.js";
|
||||||
|
|
||||||
|
const roots: string[] = [];
|
||||||
|
afterEach(() => roots.splice(0).forEach(root => rmSync(root, { recursive: true, force: true })));
|
||||||
|
const commit = "a".repeat(40);
|
||||||
|
const configuration = { workspaceId: "chinook", engine: "postgres", databaseName: "chinook", schema: "public",
|
||||||
|
binding: { transport: "postgres_direct", host: "database", port: 5432, username: "reader" } };
|
||||||
|
function setup(environment: Record<string, string> = {}) {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), "installation-binding-")); roots.push(root);
|
||||||
|
const secrets = new WorkspaceSecretStore({ root, installationId: "installation" });
|
||||||
|
const repository = new MemoryCatalogRepository();
|
||||||
|
const registry = {
|
||||||
|
read: vi.fn(async () => ({ workspace: { workspace: { schema_version: 4, id: "chinook", name: "Chinook", language: "en" } },
|
||||||
|
revision: { id: "chinook", commit, blob: "b".repeat(40) } })),
|
||||||
|
} as unknown as WorkspaceRegistry;
|
||||||
|
const app = buildApp(loadConfig({ NODE_ENV: "test", THT_HARNESS_DIR: "/missing", ...environment }), {
|
||||||
|
workspaceRegistry: registry, workspaceSecretStore: secrets, catalogRepository: repository,
|
||||||
|
catalogPostgresAccess: { connect: async () => ({ query: async () => ({ rows: [{ database: "chinook", schema: "public" }] }), end: async () => {} }) } as never,
|
||||||
|
});
|
||||||
|
const apply = (values = { password: "private-test-password" }) => app.inject({ method: "POST", url: "/installation/bindings",
|
||||||
|
payload: { schemaVersion: 1, revision: commit, configuration, secrets: values, evidenceSecrets: {} } });
|
||||||
|
return { app, apply, repository, secrets, registry };
|
||||||
|
}
|
||||||
|
|
||||||
|
test("prepared binding is imported once and equivalent rerun preserves credentials and version", async () => {
|
||||||
|
const { app, apply, repository, secrets } = setup();
|
||||||
|
try {
|
||||||
|
const first = await apply(); expect(first.statusCode).toBe(200);
|
||||||
|
expect(first.json()).toMatchObject({ status: "applied", connectionStatus: "reachable" });
|
||||||
|
const generation = secrets.generation("chinook");
|
||||||
|
const before = await repository.getByWorkspace("chinook");
|
||||||
|
const second = await apply(); expect(second.statusCode).toBe(200);
|
||||||
|
expect(second.json()).toMatchObject({ status: "unchanged", databaseId: before!.id, version: before!.version });
|
||||||
|
expect(secrets.generation("chinook")).toBe(generation);
|
||||||
|
expect(await repository.list()).toHaveLength(1);
|
||||||
|
expect(second.body).not.toContain("private-test-password");
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("released pipe client uses real local login, CSRF and logout without exposing credentials", async () => {
|
||||||
|
const original = setup(); await original.app.close();
|
||||||
|
const registry = original.registry;
|
||||||
|
registry.prepareInstallation = async () => ({ revision: commit });
|
||||||
|
const fixture = await createLocalAuthFixture({ workspaceRegistry: registry,
|
||||||
|
workspaceSecretStore: original.secrets, catalogRepository: original.repository,
|
||||||
|
catalogPostgresAccess: { connect: async () => ({ query: async () => ({ rows: [{ database: "chinook", schema: "public" }] }), end: async () => {} }) } as never,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const address = await fixture.app.listen({ host: "127.0.0.1", port: 0 });
|
||||||
|
const payload = { username: "Admin", password: localPassword, origin: fixture.publicUrl,
|
||||||
|
source: { remote: "https://example.invalid/workspaces.git", branch: "main", revision: commit,
|
||||||
|
files: { "thoth-workspaces.yaml": "a".repeat(64) } },
|
||||||
|
databases: [{ schemaVersion: 1, configuration, secrets: { password: "private-test-password" }, evidenceSecrets: {} }] };
|
||||||
|
const run = () => new Promise<{ code: number | null; output: string }>((resolve, reject) => {
|
||||||
|
const child = spawn(process.execPath, ["--input-type=module", "-e",
|
||||||
|
`import { importPreparedBindings } from '../tools/tht/internal/installapply/import-bindings.mjs'; await importPreparedBindings(${JSON.stringify(address)});`], {
|
||||||
|
env: process.env, stdio: ["pipe", "pipe", "pipe"],
|
||||||
|
});
|
||||||
|
let output = ""; child.stdout.on("data", data => { output += data; }); child.stderr.on("data", data => { output += data; });
|
||||||
|
child.once("error", reject); child.once("close", code => resolve({ code, output }));
|
||||||
|
child.stdin.end(JSON.stringify(payload));
|
||||||
|
});
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
const result = await run();
|
||||||
|
expect(result).toEqual({ code: 0, output: JSON.stringify({ ok: true, code: "bindings_ready", completed: 1 }) });
|
||||||
|
}
|
||||||
|
expect(await original.repository.list()).toHaveLength(1);
|
||||||
|
} finally { await fixture.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("administrative binding and credential changes require reconciliation without overwriting", async () => {
|
||||||
|
const { app, apply, repository, secrets } = setup();
|
||||||
|
try {
|
||||||
|
expect((await apply()).statusCode).toBe(200);
|
||||||
|
const current = (await repository.getByWorkspace("chinook"))!;
|
||||||
|
secrets.put("chinook", "catalog.dwh.password", "changed-by-administrator");
|
||||||
|
expect((await apply()).statusCode).toBe(409);
|
||||||
|
expect(secrets.matches("chinook", "catalog.dwh.password", "changed-by-administrator")).toBe(true);
|
||||||
|
const modified = { ...current, binding: { ...current.binding, host: "different-database" } };
|
||||||
|
await repository.update(current.id, current.version, modified);
|
||||||
|
expect((await apply()).statusCode).toBe(409);
|
||||||
|
expect((await repository.get(current.id))!.binding.host).toBe("different-database");
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a manually configured binding is never silently adopted", async () => {
|
||||||
|
const { app, apply, repository } = setup();
|
||||||
|
try {
|
||||||
|
const created = await app.inject({ method: "POST", url: "/catalog/databases", payload: configuration });
|
||||||
|
expect(created.statusCode).toBe(201);
|
||||||
|
expect((await apply()).statusCode).toBe(409);
|
||||||
|
expect(await repository.list()).toHaveLength(1);
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("administrative deletion remains a reconciliation stop rather than recreating a binding", async () => {
|
||||||
|
const { app, apply, repository, secrets } = setup();
|
||||||
|
try {
|
||||||
|
expect((await apply()).statusCode).toBe(200);
|
||||||
|
const database = (await repository.getByWorkspace("chinook"))!;
|
||||||
|
const deleted = await app.inject({ method: "DELETE", url: `/catalog/databases/${database.id}?version=${database.version}` });
|
||||||
|
expect(deleted.statusCode).toBe(204);
|
||||||
|
expect((await apply()).statusCode).toBe(409);
|
||||||
|
expect(await repository.list()).toHaveLength(0);
|
||||||
|
expect(secrets.has("chinook", "catalog.dwh.password")).toBe(false);
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("interruption after Catalog commit resumes the same identity without a host journal", async () => {
|
||||||
|
const { app, apply, repository } = setup();
|
||||||
|
const create = repository.create.bind(repository);
|
||||||
|
vi.spyOn(repository, "create").mockImplementationOnce(async (...args) => {
|
||||||
|
await create(...args); throw new Error("simulated connection loss after commit");
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
expect((await apply()).statusCode).toBe(503);
|
||||||
|
const current = (await repository.getByWorkspace("chinook"))!;
|
||||||
|
expect((await apply()).json()).toMatchObject({ databaseId: current.id, connectionStatus: "reachable" });
|
||||||
|
expect(await repository.list()).toHaveLength(1);
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("concurrent imports cannot duplicate or replace credentials", async () => {
|
||||||
|
const { app, apply, repository, secrets } = setup();
|
||||||
|
let entered!: () => void;
|
||||||
|
let release!: () => void;
|
||||||
|
const started = new Promise<void>(resolve => { entered = resolve; });
|
||||||
|
const continueCreation = new Promise<void>(resolve => { release = resolve; });
|
||||||
|
const create = repository.create.bind(repository);
|
||||||
|
vi.spyOn(repository, "create").mockImplementationOnce(async (...args) => {
|
||||||
|
entered(); await continueCreation; return create(...args);
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const first = apply();
|
||||||
|
await started;
|
||||||
|
const second = await apply();
|
||||||
|
release();
|
||||||
|
const results = [await first, second];
|
||||||
|
expect(results.map(result => result.statusCode).sort()).toEqual([200, 409]);
|
||||||
|
expect(await repository.list()).toHaveLength(1);
|
||||||
|
expect(secrets.matches("chinook", "catalog.dwh.password", "private-test-password")).toBe(true);
|
||||||
|
} finally { release(); await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test("imports and source activation require an authenticated administrator", async () => {
|
||||||
|
const { app, repository } = setup({ AUTH_MODE: "upstream" });
|
||||||
|
try {
|
||||||
|
for (const url of ["/installation/bindings", "/installation/workspace-source"]) {
|
||||||
|
expect((await app.inject({ method: "POST", url, payload: {} })).statusCode).toBe(401);
|
||||||
|
expect((await app.inject({ method: "POST", url, payload: {}, headers: {
|
||||||
|
"x-thoth-principal-issuer": "portal", "x-thoth-principal-subject": "reader", "x-thoth-is-admin": "0",
|
||||||
|
} })).statusCode).toBe(403);
|
||||||
|
}
|
||||||
|
expect(await repository.list()).toHaveLength(0);
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { chmodSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { rootCertificates } from "node:tls";
|
||||||
|
import { afterEach, expect, test } from "vitest";
|
||||||
|
|
||||||
|
const binary = process.env.THT_INSTALLATION_TEST_CLI;
|
||||||
|
const roots: string[] = [];
|
||||||
|
afterEach(() => roots.splice(0).forEach((path) => rmSync(path, { recursive: true, force: true })));
|
||||||
|
function run(...args: string[]) {
|
||||||
|
return spawnSync(binary!, [...args, "--json"], { encoding: "utf8", env: { ...process.env, PATH: "" }, input: "" });
|
||||||
|
}
|
||||||
|
|
||||||
|
test.skipIf(!binary)("operator prepares, completes and repeatedly validates before any stack exists", () => {
|
||||||
|
const root = realpathSync(mkdtempSync(join(tmpdir(), "application-documents-"))); roots.push(root);
|
||||||
|
const workspace = join(root, "workspaces"), directory = join(root, "installation");
|
||||||
|
expect(run("workspace", "prepare", "--directory", workspace, "--id", "practice", "--name", "Practice").status).toBe(0);
|
||||||
|
expect(run("installation", "prepare", "--directory", directory).status).toBe(0);
|
||||||
|
const installation = join(directory, "thothii-installation.yaml");
|
||||||
|
const validate = () => run("--installation", installation, "installation", "validate", "--workspaces", workspace);
|
||||||
|
expect(validate().status).toBe(1); // Visible placeholders cannot be approved.
|
||||||
|
expect(run("installation", "credentials", "--directory", directory).status).toBe(0);
|
||||||
|
for (const name of ["thothii-installation.yaml", "operator.env", "database-bootstrap.yaml"]) {
|
||||||
|
const path = join(directory, name);
|
||||||
|
writeFileSync(path, readFileSync(path, "utf8").replaceAll("CHANGE_ME", "practice"));
|
||||||
|
}
|
||||||
|
for (const [name, contents] of Object.entries({ "secrets.env": "OPENAI_API_KEY=PRIVATE_PROVIDER_VALUE\n", "database-password": "PRIVATE_DATABASE_VALUE", "git-credentials": "", "git-ca.pem": rootCertificates[0] })) {
|
||||||
|
writeFileSync(join(directory, "secrets", name), contents, { mode: 0o600 });
|
||||||
|
}
|
||||||
|
const before = readFileSync(installation, "utf8");
|
||||||
|
for (let index = 0; index < 2; index++) {
|
||||||
|
const checked = validate();
|
||||||
|
expect(checked.stderr).toBe("");
|
||||||
|
expect(checked.stdout).not.toContain("PRIVATE_");
|
||||||
|
expect(checked.status, checked.stdout).toBe(0);
|
||||||
|
expect(JSON.parse(checked.stdout).deferred_checks).toContain("release-assets");
|
||||||
|
}
|
||||||
|
expect(readFileSync(installation, "utf8")).toBe(before);
|
||||||
|
writeFileSync(installation, before.replace("interaction: openai/gpt-4.1-mini", "interaction: openai/nonexistent"));
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
writeFileSync(installation, before);
|
||||||
|
const authFile = join(directory, "secrets/pi-auth.json");
|
||||||
|
writeFileSync(authFile, "not-json");
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
writeFileSync(installation, before.replace("{mode: secret_env, apiKeyEnv: OPENAI_API_KEY}", "{mode: pi_auth}"));
|
||||||
|
writeFileSync(authFile, JSON.stringify({ openai: { unrelated: true } }));
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
writeFileSync(authFile, JSON.stringify({ " OpenAI ": { type: "api_key", key: "PRIVATE_PI_KEY" } }));
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
writeFileSync(authFile, JSON.stringify({ openai: { type: "api_key", key: "PRIVATE_PI_KEY" } }));
|
||||||
|
expect(validate().status).toBe(0);
|
||||||
|
writeFileSync(installation, before);
|
||||||
|
writeFileSync(authFile, "{}");
|
||||||
|
const bootstrap = join(directory, "database-bootstrap.yaml");
|
||||||
|
const originalBootstrap = readFileSync(bootstrap, "utf8");
|
||||||
|
writeFileSync(join(workspace, "practice", "private-password"), "PRIVATE_DATABASE_VALUE", { mode: 0o600 });
|
||||||
|
writeFileSync(bootstrap, originalBootstrap.replace(join(directory, "secrets/database-password"), join(workspace, "practice/private-password")));
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
writeFileSync(bootstrap, originalBootstrap);
|
||||||
|
chmodSync(join(directory, "secrets/database-password"), 0o644);
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
chmodSync(join(directory, "secrets/database-password"), 0o600);
|
||||||
|
const env = join(directory, "operator.env");
|
||||||
|
writeFileSync(env, readFileSync(env, "utf8") + "THOTH_HTTP_PORT=8081\n");
|
||||||
|
expect(validate().status).toBe(1);
|
||||||
|
}, 15_000);
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { createServer } from "node:http";
|
||||||
|
import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { expect, it } from "vitest";
|
||||||
|
import { probeBootstrapDependencies } from "../src/catalog/bootstrap-probes.js";
|
||||||
|
import { probePublicEvidenceUrl } from "../src/catalog/evidence-probe-http.js";
|
||||||
|
|
||||||
|
it("refuses loopback literals and DNS answers before sending an Evidence GET", async () => {
|
||||||
|
for (const hostname of ["[::1]", "127.0.0.1", "localhost", "[::ffff:127.0.0.1]"]) {
|
||||||
|
await expect(probePublicEvidenceUrl(new URL(`http://${hostname}/private`))).rejects.toThrow("Evidence network policy refused");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("authenticates a bounded read-only REST probe and blocks unavailable credentials/services", async () => {
|
||||||
|
const directory = mkdtempSync(join(tmpdir(), "tht-probe-"));
|
||||||
|
const secret = join(directory, "key");
|
||||||
|
writeFileSync(secret, "PRIVATE_SENTINEL", { mode: 0o600 });
|
||||||
|
let status = 200;
|
||||||
|
const requests: string[] = [];
|
||||||
|
const server = createServer((req, res) => {
|
||||||
|
requests.push(`${req.method} ${req.url}`);
|
||||||
|
res.writeHead(req.headers.authorization === "Bearer PRIVATE_SENTINEL" ? status : 401);
|
||||||
|
res.end("PRIVATE_SERVER_RESPONSE");
|
||||||
|
});
|
||||||
|
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
||||||
|
const address = server.address() as { port: number };
|
||||||
|
const document = { schemaVersion: 1, databases: [{ workspaceId: "demo", engine: "postgres", databaseName: "demo", schema: "public", binding: { transport: "rest_api", baseUrl: `http://127.0.0.1:${address.port}`, restPath: "/health", restAuth: "bearer" }, secretFiles: { apiKey: secret } }] };
|
||||||
|
try {
|
||||||
|
expect((await probeBootstrapDependencies(document)).ok).toBe(true);
|
||||||
|
status = 503;
|
||||||
|
const failed = await probeBootstrapDependencies(document);
|
||||||
|
expect(failed.ok).toBe(false);
|
||||||
|
expect(JSON.stringify(failed)).not.toContain("PRIVATE");
|
||||||
|
status = 200;
|
||||||
|
writeFileSync(secret, "rotated-but-invalid");
|
||||||
|
expect((await probeBootstrapDependencies(document)).ok).toBe(false);
|
||||||
|
expect(requests).toEqual(["GET /health", "GET /health", "GET /health"]);
|
||||||
|
} finally {
|
||||||
|
await new Promise<void>((resolve) => server.close(() => resolve()));
|
||||||
|
rmSync(directory, { recursive: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import { expect, test } from "vitest";
|
||||||
|
// The shipped operator client is plain ESM, shared by the embedded command and these API-boundary tests.
|
||||||
|
// @ts-expect-error JavaScript operator module has no separate declaration file.
|
||||||
|
import { prepareWorkspace, importBinding } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||||
|
|
||||||
|
const revision = "a".repeat(40);
|
||||||
|
|
||||||
|
test("a stranded preprocessing state requests guarded recovery, then verifies fresh readiness", async () => {
|
||||||
|
let state = "running";
|
||||||
|
const request = async (path: string, body?: unknown): Promise<Response> => {
|
||||||
|
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2, schemaSyncedVersion: 2,
|
||||||
|
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||||
|
if (path.endsWith("/sync-runs")) return Response.json([]);
|
||||||
|
if (path.endsWith("/preprocessing")) {
|
||||||
|
if (body) { expect(body).toEqual({ recoverInterrupted: true }); state = "ready"; }
|
||||||
|
return Response.json({ state });
|
||||||
|
}
|
||||||
|
throw Error("unexpected operation");
|
||||||
|
};
|
||||||
|
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("retry reaches a pending human schema review even when its reservation blocks binding import", async () => {
|
||||||
|
const request = async (path: string) => {
|
||||||
|
if (path === "/installation/bindings") return Response.json({ code: "installation_operation_pending" }, { status: 409 });
|
||||||
|
if (path === "/catalog/databases") return Response.json([{ workspaceId: "chinook", activeSyncRun: { id: "run-id", state: "awaiting_confirmation" } }]);
|
||||||
|
throw Error("unexpected operation");
|
||||||
|
};
|
||||||
|
await expect(importBinding(request, { configuration: { workspaceId: "chinook" } }, revision, async () => {})).rejects.toMatchObject({ code: "schema_review_required", runId: "run-id" });
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(["blocked", "failed"])("configured Evidence/index failure (%s) remains a real stop", async state => {
|
||||||
|
const request = async (path: string, body?: unknown): Promise<Response> => {
|
||||||
|
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2, schemaSyncedVersion: 2,
|
||||||
|
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||||
|
if (path.endsWith("/sync-runs")) return Response.json([]);
|
||||||
|
if (path.endsWith("/preprocessing")) return Response.json({ state }, { status: body === undefined ? 200 : 422 });
|
||||||
|
throw Error("unexpected destructive operation");
|
||||||
|
};
|
||||||
|
await expect(prepareWorkspace(request, "chinook", revision, async () => {})).rejects.toMatchObject({ code: `preprocessing_${state}` });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("SSH metadata connectivity cannot be mistaken for session transport support", async () => {
|
||||||
|
const calls: string[] = [];
|
||||||
|
const request = async (path: string) => {
|
||||||
|
calls.push(path);
|
||||||
|
return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||||
|
binding: { transport: "ssh_tunnel" }, workspaceRevision: { commit: revision } }]);
|
||||||
|
};
|
||||||
|
await expect(prepareWorkspace(request, "chinook", revision)).rejects.toMatchObject({ code: "session_transport_unsupported" });
|
||||||
|
expect(calls).toEqual(["/catalog/databases"]);
|
||||||
|
});
|
||||||
|
test("a destructive synchronization stops at the existing domain gate without confirmation", async () => {
|
||||||
|
const calls: string[] = [];
|
||||||
|
const request = async (path: string) => {
|
||||||
|
calls.push(path);
|
||||||
|
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||||
|
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||||
|
if (path.endsWith("/sync-runs")) return Response.json([{ id: "run-id", state: "awaiting_confirmation", scope: "all" }]);
|
||||||
|
throw Error("unexpected operation");
|
||||||
|
};
|
||||||
|
await expect(prepareWorkspace(request, "chinook", revision)).rejects.toMatchObject({ code: "schema_review_required", runId: "run-id" });
|
||||||
|
expect(calls).toEqual(["/catalog/databases", "/catalog/databases/database-id/sync-runs"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("fresh additive sync and preprocessing use existing APIs once, then repeat as a no-op", async () => {
|
||||||
|
const writes: string[] = [];
|
||||||
|
let synchronized = false, preprocessed = false;
|
||||||
|
const request = async (path: string, body?: unknown) => {
|
||||||
|
if (body !== undefined) writes.push(path);
|
||||||
|
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2,
|
||||||
|
schemaSyncedVersion: synchronized ? 2 : undefined,
|
||||||
|
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||||
|
if (path === "/catalog/databases/database-id") return Response.json({ version: 2, schemaSyncedVersion: 2 });
|
||||||
|
if (path.endsWith("/sync-runs")) {
|
||||||
|
if (body) { expect(body).toEqual({ version: 2, scope: "all", tableIds: [] }); return Response.json({ id: "run-id", state: "queued", scope: "all" }); }
|
||||||
|
return Response.json(synchronized ? [{ id: "run-id", state: "succeeded", scope: "all" }] : []);
|
||||||
|
}
|
||||||
|
if (path === "/catalog/sync-runs/run-id") { synchronized = true; return Response.json({ id: "run-id", state: "succeeded", scope: "all" }); }
|
||||||
|
if (path === "/workspaces/chinook/preprocessing") {
|
||||||
|
if (body) preprocessed = true;
|
||||||
|
return Response.json({ state: preprocessed ? "ready" : "required" });
|
||||||
|
}
|
||||||
|
throw Error("unexpected operation");
|
||||||
|
};
|
||||||
|
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||||
|
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||||
|
expect(writes).toEqual(["/catalog/databases/database-id/sync-runs", "/workspaces/chinook/preprocessing"]);
|
||||||
|
});
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { execFileSync } from "node:child_process";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readFileSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { afterEach, expect, test } from "vitest";
|
||||||
|
import { WorkspaceRegistry } from "../src/workspaces/registry.js";
|
||||||
|
const roots: string[] = [];
|
||||||
|
afterEach(() => roots.splice(0).forEach(root => rmSync(root, { recursive: true, force: true })));
|
||||||
|
test("activates only the prepared source contents and never retargets an existing checkout", async () => {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), "installation-source-")); roots.push(root);
|
||||||
|
const remote = join(root, "source"); mkdirSync(join(remote, "chinook"), { recursive: true });
|
||||||
|
const files: Record<string, string> = {
|
||||||
|
"thoth-workspaces.yaml": "schema_version: 1\nworkspaces: [{id: chinook, name: Chinook}]\n",
|
||||||
|
"chinook/workspace.yaml": "workspace:\n schema_version: 4\n id: chinook\n name: Chinook\n language: en\n",
|
||||||
|
};
|
||||||
|
for (const [path, value] of Object.entries(files)) writeFileSync(join(remote, path), value);
|
||||||
|
const git = (args: string[], cwd = remote) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
||||||
|
git(["init", "-b", "main"]); git(["add", "."]);
|
||||||
|
git(["-c", "user.name=Test", "-c", "user.email=test@example.invalid", "commit", "-m", "fixture"]);
|
||||||
|
const revision = git(["rev-parse", "HEAD"]);
|
||||||
|
const config = { root: join(root, "registry"), remoteUrl: remote, branch: "main", installationId: "test", secretRoots: [] };
|
||||||
|
const registry = new WorkspaceRegistry(config);
|
||||||
|
const expected = { remote, branch: "main", revision, files: Object.fromEntries(Object.entries(files).map(([path, value]) => [path, createHash("sha256").update(value).digest("hex")])) };
|
||||||
|
await expect(registry.prepareInstallation({ ...expected, files: { ...expected.files, "chinook/workspace.yaml": "0".repeat(64) } })).rejects.toThrow();
|
||||||
|
await expect(registry.verifyStoredState()).rejects.toThrow();
|
||||||
|
await expect(registry.prepareInstallation(expected)).resolves.toMatchObject({ revision });
|
||||||
|
await expect(registry.prepareInstallation(expected)).resolves.toMatchObject({ revision });
|
||||||
|
const checkout = join(config.root, "repo");
|
||||||
|
git(["remote", "set-url", "origin", join(root, "another")], checkout);
|
||||||
|
await expect(registry.prepareInstallation(expected)).rejects.toThrow();
|
||||||
|
expect(git(["remote", "get-url", "origin"], checkout)).toBe(join(root, "another"));
|
||||||
|
expect(readFileSync(join(checkout, "chinook/workspace.yaml"), "utf8")).toBe(files["chinook/workspace.yaml"]);
|
||||||
|
});
|
||||||
@@ -95,6 +95,35 @@ test("returns empty catalogs when no runtime projection is configured", () => {
|
|||||||
expect(loadMetadataGenerationModels({}).catalog()).toEqual({ models: [], default: null });
|
expect(loadMetadataGenerationModels({}).catalog()).toEqual({ models: [], default: null });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
["qwen-chat-template", true, true],
|
||||||
|
["qwen", true, true],
|
||||||
|
["qwen-typo", true, false],
|
||||||
|
["qwen-chat-template", false, false],
|
||||||
|
])("validates Qwen thinking format %s with reasoning=%s", (thinkingFormat, reasoning, valid) => {
|
||||||
|
const { catalogFile } = runtimeCatalog({
|
||||||
|
defaultInteraction: "local/qwen",
|
||||||
|
models: [{
|
||||||
|
id: "local/qwen", provider: "local", model: "qwen", label: "Qwen",
|
||||||
|
upstreamModel: "qwen", endpoint: { baseUrl: "http://localhost:8000/v1" },
|
||||||
|
authentication: { mode: "none" }, sessionAdapter: { mode: "openai_compatible" },
|
||||||
|
session: {
|
||||||
|
reasoning, contextWindow: 32768, maxTokens: 8192,
|
||||||
|
compatibility: {
|
||||||
|
supportsDeveloperRole: false, supportsReasoningEffort: false,
|
||||||
|
supportsStore: false, maxTokensField: "max_tokens", thinkingFormat,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
if (valid) {
|
||||||
|
expect(loadRuntimeModelCatalog(catalogFile).sessionModels()[0].session?.compatibility)
|
||||||
|
.toMatchObject({ thinkingFormat });
|
||||||
|
} else {
|
||||||
|
expect(() => loadRuntimeModelCatalog(catalogFile)).toThrow("runtime model catalog is invalid");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test("rejects a drifted default and an unprotected projection", () => {
|
test("rejects a drifted default and an unprotected projection", () => {
|
||||||
const drifted = runtimeCatalog({ defaultInteraction: "zai/missing" });
|
const drifted = runtimeCatalog({ defaultInteraction: "zai/missing" });
|
||||||
expect(() => loadRuntimeModelCatalog(drifted.catalogFile)).toThrow("interaction default is invalid");
|
expect(() => loadRuntimeModelCatalog(drifted.catalogFile)).toThrow("interaction default is invalid");
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ vi.mock("../src/tht/tht-runner.js", () => ({
|
|||||||
|
|
||||||
vi.mock("../src/workspaces/registry.js", () => ({
|
vi.mock("../src/workspaces/registry.js", () => ({
|
||||||
WorkspaceRegistry: class {
|
WorkspaceRegistry: class {
|
||||||
|
async pull() {
|
||||||
|
return { branch: "main", head: "a".repeat(40), ahead: 0, behind: 0, degraded: false };
|
||||||
|
}
|
||||||
|
|
||||||
async listRetainedSnapshots() {
|
async listRetainedSnapshots() {
|
||||||
return [{ snapshotPath: "/data/workspace-registry/snapshots/revision/workspace.yaml" }];
|
return [{ snapshotPath: "/data/workspace-registry/snapshots/revision/workspace.yaml" }];
|
||||||
}
|
}
|
||||||
@@ -98,3 +102,13 @@ test("workflow doctor gives schema-v4 runtime rendering a live Catalog repositor
|
|||||||
expect(fakes.releaseWorkspaceRuntime).toHaveBeenCalledOnce();
|
expect(fakes.releaseWorkspaceRuntime).toHaveBeenCalledOnce();
|
||||||
expect(fakes.catalogRepository.close).toHaveBeenCalledOnce();
|
expect(fakes.catalogRepository.close).toHaveBeenCalledOnce();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("workspace pull exposes only safe Git status", async () => {
|
||||||
|
await expect(runOperatorAction("workspace-pull", config)).resolves.toEqual({
|
||||||
|
ready: true,
|
||||||
|
status: "succeeded",
|
||||||
|
branch: "main",
|
||||||
|
head: "a".repeat(40),
|
||||||
|
degraded: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -54,6 +54,17 @@ const modelCatalog: RuntimeModelCatalog = {
|
|||||||
hasSession: (id) => id === "zai/glm-5.2",
|
hasSession: (id) => id === "zai/glm-5.2",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test("a fresh installation can smoke-test its catalog default without saved user settings", async () => {
|
||||||
|
const smokeProvider = vi.fn(async () => undefined);
|
||||||
|
const service = createPiManagement(configFor(), {
|
||||||
|
modelCatalog, execute: successfulExec([]), readSettings: () => ({}), smokeProvider,
|
||||||
|
});
|
||||||
|
expect(await service.test()).toMatchObject({ ready: true });
|
||||||
|
expect(smokeProvider).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
|
provider: "zai", model: "glm-5.2", reasoning: "low",
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
function successfulExec(calls: Array<{ command: string; args: string[]; timeout: number }>): PiExecFile {
|
function successfulExec(calls: Array<{ command: string; args: string[]; timeout: number }>): PiExecFile {
|
||||||
return async (command, args, options) => {
|
return async (command, args, options) => {
|
||||||
calls.push({ command, args, timeout: options.timeout });
|
calls.push({ command, args, timeout: options.timeout });
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { mkdtempSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { spawn, spawnSync } from "node:child_process";
|
||||||
|
import { expect, test } from "vitest";
|
||||||
|
import { acquirePreprocessingOwner, guardedPreprocessingCommand } from "../src/workspaces/preprocessing-owner.js";
|
||||||
|
|
||||||
|
test("orphan worker prevents recovery; delayed old worker is fenced after recovery", async () => {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), "preprocess-owner-"));
|
||||||
|
let worker;
|
||||||
|
try {
|
||||||
|
const owner = await acquirePreprocessingOwner(root, "chinook");
|
||||||
|
const command = guardedPreprocessingCommand(owner.guard, "python3", ["-c", "import time; print('ready',flush=True); time.sleep(30)"]);
|
||||||
|
worker = spawn(command.executable, command.args, { stdio: ["ignore", "pipe", "pipe"] });
|
||||||
|
await new Promise<void>((resolve, reject) => { worker!.stdout!.once("data", () => resolve()); worker!.once("error", reject); worker!.once("exit", () => reject(Error("worker stopped early"))); });
|
||||||
|
await owner.release();
|
||||||
|
await expect(acquirePreprocessingOwner(root, "chinook")).rejects.toMatchObject({ code: "preprocessing_conflict" });
|
||||||
|
const exited = new Promise(resolve => worker!.once("exit", resolve)); worker.kill("SIGKILL"); await exited;
|
||||||
|
const replacement = await acquirePreprocessingOwner(root, "chinook");
|
||||||
|
try {
|
||||||
|
const stale = guardedPreprocessingCommand(owner.guard, "python3", ["-c", "raise Exception('must never run')"]);
|
||||||
|
expect(spawnSync(stale.executable, stale.args).status).toBe(73);
|
||||||
|
} finally { await replacement.release(); }
|
||||||
|
} finally { worker?.kill("SIGKILL"); rmSync(root, { recursive: true, force: true }); }
|
||||||
|
});
|
||||||
@@ -140,6 +140,33 @@ test("resume rejects browser interaction language overrides", async () => {
|
|||||||
} finally { await app.close(); }
|
} finally { await app.close(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("new session starts Pi with the question language persisted by the harness", async () => {
|
||||||
|
let runtime: any;
|
||||||
|
const app = buildApp(loadConfig({ THT_HARNESS_DIR: "../harness" }), {
|
||||||
|
thtRunner: {
|
||||||
|
sessionNew: async () => ({ id: "english-question", interaction_language: "en" }),
|
||||||
|
searchPack: async () => {},
|
||||||
|
},
|
||||||
|
readiness: { ensure: async () => ({ ok: true }) },
|
||||||
|
mgr: {
|
||||||
|
get: () => undefined,
|
||||||
|
createFor: (_id: string, options: any) => {
|
||||||
|
runtime = options;
|
||||||
|
return { bridge: { onClientEvent: () => {} } };
|
||||||
|
},
|
||||||
|
configure: async () => {}, start: () => {},
|
||||||
|
},
|
||||||
|
getSettings: () => ({ workspace: "default" }),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const response = await app.inject({ method: "POST", url: "/sessions", payload: {
|
||||||
|
question: "How many patients were admitted last year?", interactionLanguage: "it",
|
||||||
|
} });
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(runtime.interactionLanguage).toBe("en");
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
test("resume pins legacy interaction language using the resolved harness workspace", async () => {
|
test("resume pins legacy interaction language using the resolved harness workspace", async () => {
|
||||||
let pinnedWorkspace: string | undefined;
|
let pinnedWorkspace: string | undefined;
|
||||||
let runtime: any;
|
let runtime: any;
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync, symlinkSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join, resolve } from "node:path";
|
||||||
|
import { afterEach, expect, test } from "vitest";
|
||||||
|
import { parseWorkspaceCatalogYaml } from "../src/workspaces/catalog.js";
|
||||||
|
import { parseWorkspaceYaml } from "../src/workspaces/schema.js";
|
||||||
|
|
||||||
|
const roots: string[] = [];
|
||||||
|
function directory() {
|
||||||
|
const root = mkdtempSync(join(tmpdir(), "tht-documents-"));
|
||||||
|
roots.push(root);
|
||||||
|
return join(root, "workspaces");
|
||||||
|
}
|
||||||
|
afterEach(() => roots.splice(0).forEach((root) => rmSync(root, { recursive: true, force: true })));
|
||||||
|
|
||||||
|
function cli(...args: string[]) {
|
||||||
|
const packaged = process.env.THT_WORKSPACE_TEST_CLI;
|
||||||
|
const result = spawnSync(packaged ?? process.execPath, [...(packaged ? ["workspace"] : ["--import", "tsx", resolve("src/workspace-documents-cli.ts")]), ...args, "--json"], {
|
||||||
|
encoding: "utf8", env: { ...process.env, PATH: "" },
|
||||||
|
});
|
||||||
|
return { ...result, report: result.stdout.trim() ? JSON.parse(result.stdout) : null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const descriptor = "workspace:\n schema_version: 4\n id: practice\n name: Practice\n language: en\n";
|
||||||
|
const catalog = "schema_version: 1\nworkspaces:\n - id: practice\n name: Practice\n";
|
||||||
|
const corpus = [
|
||||||
|
{ name: "minimal", descriptor, catalog, valid: true },
|
||||||
|
{ name: "optional Evidence", descriptor: descriptor + "evidence:\n source:\n type: http\n uris: [https://example.com/manual.md]\n", catalog, valid: true },
|
||||||
|
{ name: "duplicate YAML key", descriptor: descriptor + " id: practice\n", catalog, valid: false },
|
||||||
|
{ name: "ambiguous document", descriptor: descriptor + "---\n" + descriptor, catalog, valid: false },
|
||||||
|
{ name: "unknown workspace field", descriptor: descriptor + " secret: VERY_SECRET_VALUE\n", catalog, valid: false },
|
||||||
|
{ name: "database binding in authored descriptor", descriptor: descriptor + "dwh: {password: VERY_SECRET_VALUE}\n", catalog, valid: false },
|
||||||
|
{ name: "duplicate catalog id", descriptor, catalog: catalog + " - id: practice\n name: Practice\n", valid: false },
|
||||||
|
{ name: "unknown catalog field", descriptor, catalog: catalog + "secret: VERY_SECRET_VALUE\n", valid: false },
|
||||||
|
{ name: "invalid catalog YAML", descriptor, catalog: catalog + "schema_version: 1\n", valid: false },
|
||||||
|
{ name: "unsafe Evidence URI", descriptor: descriptor + "evidence:\n source:\n type: http\n uris: [https://user:VERY_SECRET_VALUE@example.com/file]\n", catalog, valid: false },
|
||||||
|
];
|
||||||
|
|
||||||
|
test.each(corpus)("CLI and runtime agree: $name", (fixture) => {
|
||||||
|
const root = directory();
|
||||||
|
mkdirSync(join(root, "practice"), { recursive: true });
|
||||||
|
writeFileSync(join(root, "thoth-workspaces.yaml"), fixture.catalog);
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), fixture.descriptor);
|
||||||
|
let accepted = true;
|
||||||
|
try { parseWorkspaceCatalogYaml(fixture.catalog); parseWorkspaceYaml(fixture.descriptor); }
|
||||||
|
catch { accepted = false; }
|
||||||
|
expect(accepted).toBe(fixture.valid);
|
||||||
|
const checked = cli("validate", "--directory", root);
|
||||||
|
expect(checked.status).toBe(fixture.valid ? 0 : 1);
|
||||||
|
expect(checked.report.ok).toBe(accepted);
|
||||||
|
expect(checked.stdout + checked.stderr).not.toContain("VERY_SECRET_VALUE");
|
||||||
|
if (!fixture.valid) {
|
||||||
|
expect(checked.report.issues[0].document).not.toBe(".");
|
||||||
|
expect(checked.report.issues[0].correction.length).toBeGreaterThan(10);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("prepare refuses existing directories and invalid options without changing documents", () => {
|
||||||
|
const root = directory();
|
||||||
|
expect(cli("prepare", "--directory", root, "--id", "practice", "--name", "Practice").status).toBe(0);
|
||||||
|
const before = readFileSync(join(root, "thoth-workspaces.yaml"), "utf8");
|
||||||
|
expect(cli("prepare", "--directory", root, "--id", "other", "--name", "Other").report.issues[0].code).toBe("destination_exists");
|
||||||
|
expect(readFileSync(join(root, "thoth-workspaces.yaml"), "utf8")).toBe(before);
|
||||||
|
expect(cli("validate", "--directory", root, "--typo", "VERY_SECRET_VALUE").status).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("validation rejects directory mismatches, missing references and symlinks without following them", () => {
|
||||||
|
const root = directory();
|
||||||
|
cli("prepare", "--directory", root, "--id", "practice", "--name", "Practice");
|
||||||
|
mkdirSync(join(root, "unlisted"));
|
||||||
|
expect(cli("validate", "--directory", root).report.issues.some((i: {code: string}) => i.code === "unlisted_directory")).toBe(true);
|
||||||
|
rmSync(join(root, "unlisted"), { recursive: true });
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), descriptor.replace("name: Practice", "name: Different"));
|
||||||
|
expect(cli("validate", "--directory", root).report.issues[0].code).toBe("catalog_mismatch");
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), descriptor + "evidence:\n source:\n type: filesystem\n uri: practice/evidence\n");
|
||||||
|
expect(cli("validate", "--directory", root).report.issues[0].code).toBe("missing_reference");
|
||||||
|
symlinkSync(roots[roots.length - 1], join(root, "practice/evidence"), "dir");
|
||||||
|
expect(cli("validate", "--directory", root).report.issues[0].code).toBe("unsafe_reference");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("local Evidence checks references and YAML frontmatter, and explicitly defers canonical content validation", () => {
|
||||||
|
const root = directory();
|
||||||
|
cli("prepare", "--directory", root, "--id", "practice", "--name", "Practice");
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), descriptor + "evidence:\n schema_version: 2\n source:\n type: filesystem\n uri: practice/evidence\n patterns: ['curated/**/*.md']\n");
|
||||||
|
mkdirSync(join(root, "practice/evidence/curated/domain"), { recursive: true });
|
||||||
|
const evidence = join(root, "practice/evidence/curated/domain/rule.md");
|
||||||
|
writeFileSync(evidence, "---\nschema_version: 4\nid: evidence:rule\nkind: domain\nlanguage: en\npurposes: [sql_generation]\n---\n# Rule\n\n## Rule\nUse the order number.\n");
|
||||||
|
const checked = cli("validate", "--directory", root);
|
||||||
|
expect(checked.status).toBe(0);
|
||||||
|
expect(checked.report.workspaces).toEqual([{ id: "practice", evidence: "local-files" }]);
|
||||||
|
expect(checked.report.deferred_checks).toContain("practice:evidence-content-provenance-and-indexing");
|
||||||
|
writeFileSync(evidence, "---\nid: first\nid: VERY_SECRET_VALUE\n---\n# Rule\n");
|
||||||
|
const invalid = cli("validate", "--directory", root);
|
||||||
|
expect(invalid.status).toBe(1);
|
||||||
|
expect(invalid.report.issues[0].document).toBe("practice/evidence/curated/domain/rule.md");
|
||||||
|
expect(invalid.stdout).not.toContain("VERY_SECRET_VALUE");
|
||||||
|
writeFileSync(join(root, "practice/workspace.yaml"), descriptor + "evidence:\n source:\n type: filesystem\n uri: practice/evidence\n patterns: [missing.md]\n");
|
||||||
|
expect(cli("validate", "--directory", root).report.issues[0].code).toBe("missing_reference");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("prepare creates documents accepted by the runtime and validate is repeatable without installation or services", () => {
|
||||||
|
const root = directory();
|
||||||
|
const prepared = cli("prepare", "--directory", root, "--id", "practice", "--name", "Practice");
|
||||||
|
expect(prepared.stderr).toBe("");
|
||||||
|
expect(prepared.status).toBe(0);
|
||||||
|
expect(prepared.report.ok).toBe(true);
|
||||||
|
const catalog = readFileSync(join(root, "thoth-workspaces.yaml"), "utf8");
|
||||||
|
const descriptor = readFileSync(join(root, "practice/workspace.yaml"), "utf8");
|
||||||
|
expect(parseWorkspaceCatalogYaml(catalog).workspaces[0].id).toBe("practice");
|
||||||
|
expect(parseWorkspaceYaml(descriptor).evidence).toBeUndefined();
|
||||||
|
for (let index = 0; index < 2; index++) {
|
||||||
|
const checked = cli("validate", "--directory", root);
|
||||||
|
expect(checked.status).toBe(0);
|
||||||
|
expect(checked.report.workspaces).toEqual([{ id: "practice", evidence: "absent" }]);
|
||||||
|
}
|
||||||
|
expect(readFileSync(join(root, "thoth-workspaces.yaml"), "utf8")).toBe(catalog);
|
||||||
|
expect(readFileSync(join(root, "practice/workspace.yaml"), "utf8")).toBe(descriptor);
|
||||||
|
});
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
type WorkspacePreprocessingRouteDeps,
|
type WorkspacePreprocessingRouteDeps,
|
||||||
} from "../src/routes/workspace-preprocessing.js";
|
} from "../src/routes/workspace-preprocessing.js";
|
||||||
import type { WorkspaceRegistry } from "../src/workspaces/registry.js";
|
import type { WorkspaceRegistry } from "../src/workspaces/registry.js";
|
||||||
|
import { PreprocessingStateError } from "../src/workspaces/preprocessing-state.js";
|
||||||
|
|
||||||
const admin: PrincipalContext = {
|
const admin: PrincipalContext = {
|
||||||
issuer: "test",
|
issuer: "test",
|
||||||
@@ -17,6 +18,22 @@ const admin: PrincipalContext = {
|
|||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test("explicit interrupted-run recovery is guarded and never steals an active owner", async () => {
|
||||||
|
const run = vi.fn(async () => { throw new PreprocessingStateError("preprocessing_conflict", "private owner details"); });
|
||||||
|
const deps = routeDeps(() => database({ preprocessingStatus: "running" }), { service: { run, clear: vi.fn() } });
|
||||||
|
const app = Fastify();
|
||||||
|
app.addHook("preHandler", async request => { request.principal = admin; });
|
||||||
|
workspacePreprocessingRoutes(app, deps);
|
||||||
|
try {
|
||||||
|
const response = await app.inject({ method: "POST", url: "/workspaces/catalog-workspace/preprocessing", payload: { recoverInterrupted: true } });
|
||||||
|
expect(response.statusCode).toBe(409);
|
||||||
|
expect(response.json()).toMatchObject({ code: "preprocessing_conflict", state: "running" });
|
||||||
|
expect(response.body).not.toContain("private owner");
|
||||||
|
expect(run).toHaveBeenCalledOnce();
|
||||||
|
expect(deps.service.clear).not.toHaveBeenCalled();
|
||||||
|
} finally { await app.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
function database(overrides: Partial<WorkspaceDatabase> = {}): WorkspaceDatabase {
|
function database(overrides: Partial<WorkspaceDatabase> = {}): WorkspaceDatabase {
|
||||||
return {
|
return {
|
||||||
id: "49b6491a-78bb-4cee-b27b-0efaf4419774",
|
id: "49b6491a-78bb-4cee-b27b-0efaf4419774",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { afterEach, expect, test, vi } from "vitest";
|
import { afterEach, expect, test, vi } from "vitest";
|
||||||
import { validateWorkspaceDescriptor } from "../src/workspaces/schema.js";
|
import { validateWorkspaceDescriptor } from "../src/workspaces/schema.js";
|
||||||
|
import { PreprocessingStateStore, type WriterLockLease } from "../src/workspaces/preprocessing-state.js";
|
||||||
import {
|
import {
|
||||||
WorkspacePreprocessingService,
|
WorkspacePreprocessingService,
|
||||||
type ChildProcessRequest,
|
type ChildProcessRequest,
|
||||||
@@ -10,6 +11,64 @@ import {
|
|||||||
|
|
||||||
const roots: string[] = [];
|
const roots: string[] = [];
|
||||||
|
|
||||||
|
test("a legacy running lease is never silently adopted by repeated recovery attempts", async () => {
|
||||||
|
const catalog = repository({ getByWorkspace: vi.fn(async () => ({ ...database, preprocessingInputFingerprint: "sha256:legacy" })) });
|
||||||
|
const instance = service({ repository: catalog });
|
||||||
|
for (let attempt = 0; attempt < 2; attempt++) {
|
||||||
|
expect(await instance.run({ workspaceId: "catalog-workspace" })).toMatchObject({ status: "failed", code: "preprocessing_conflict" });
|
||||||
|
}
|
||||||
|
expect(catalog.beginPreprocessing).not.toHaveBeenCalled();
|
||||||
|
expect(catalog.finishPreprocessing).not.toHaveBeenCalled();
|
||||||
|
expect(catalog.clearPreprocessing).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("retry after loss of Catalog completion restarts guarded preprocessing without clearing data", async () => {
|
||||||
|
let stranded = false;
|
||||||
|
let runId: string | undefined;
|
||||||
|
const catalog = repository({ getByWorkspace: vi.fn(async () => ({ ...database,
|
||||||
|
...(stranded ? { preprocessingInputFingerprint: "sha256:" + "f".repeat(64), preprocessingRunId: runId } : {}) })),
|
||||||
|
beginPreprocessing: vi.fn(async (_workspace, _fingerprint, id) => {
|
||||||
|
runId = id; return { kind: "started", database };
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
catalog.finishPreprocessing.mockRejectedValueOnce(Error("Catalog connection lost"))
|
||||||
|
.mockRejectedValueOnce(Error("Catalog still unavailable"));
|
||||||
|
const instance = service({ repository: catalog, runChild: async () => {
|
||||||
|
stranded = true;
|
||||||
|
return { exitCode: 0, stdout: JSON.stringify({ counts: { tables: 1 } }), stderr: "" };
|
||||||
|
} });
|
||||||
|
await expect(instance.run({ workspaceId: "catalog-workspace" })).rejects.toThrow();
|
||||||
|
const second = await instance.run({ workspaceId: "catalog-workspace" });
|
||||||
|
expect(second.status).toBe("succeeded");
|
||||||
|
expect(catalog.finishPreprocessing).toHaveBeenCalledWith("catalog-workspace", 9, "sha256:" + "f".repeat(64),
|
||||||
|
{ status: "failed", errorCode: "preprocessing_interrupted" }, expect.any(String));
|
||||||
|
expect(catalog.clearPreprocessing).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("loss of the real owner during semantic preflight cannot complete or rewrite the job", async () => {
|
||||||
|
let lease: WriterLockLease | undefined;
|
||||||
|
const original = PreprocessingStateStore.prototype.acquireWriterLock;
|
||||||
|
const spy = vi.spyOn(PreprocessingStateStore.prototype, "acquireWriterLock")
|
||||||
|
.mockImplementation(async function (kind) {
|
||||||
|
const acquired = await original.call(this, kind);
|
||||||
|
if (kind !== "workers") lease = acquired;
|
||||||
|
return acquired;
|
||||||
|
});
|
||||||
|
const catalog = repository();
|
||||||
|
const instance = service({ repository: catalog, semanticPreflight: async () => {
|
||||||
|
process.kill(lease!.holderPid, "SIGKILL");
|
||||||
|
for (let i = 0; i < 100 && lease!.isHeld(); i++) await new Promise(resolve => setTimeout(resolve, 10));
|
||||||
|
expect(lease!.isHeld()).toBe(false);
|
||||||
|
return { ok: false, code: "semantic_index_incompatible" };
|
||||||
|
} });
|
||||||
|
try {
|
||||||
|
await expect(instance.run({ workspaceId: "catalog-workspace" })).rejects.toMatchObject({ code: "preprocessing_conflict" });
|
||||||
|
expect(catalog.finishPreprocessing).not.toHaveBeenCalled();
|
||||||
|
const latest = new PreprocessingStateStore({ dataRoot: roots.at(-1)!, workspaceId: "catalog-workspace" }).readLatestJob();
|
||||||
|
expect(latest?.status).toBe("active");
|
||||||
|
} finally { spy.mockRestore(); }
|
||||||
|
});
|
||||||
|
|
||||||
test("Evidence consolidation runs only its stage and preserves blocked Catalog readiness", async () => {
|
test("Evidence consolidation runs only its stage and preserves blocked Catalog readiness", async () => {
|
||||||
const catalog = repository();
|
const catalog = repository();
|
||||||
const runChild = vi.fn(async () => ({ exitCode: 0, stdout: JSON.stringify({ status: "succeeded", counts: { documents: 2 } }), stderr: "" }));
|
const runChild = vi.fn(async () => ({ exitCode: 0, stdout: JSON.stringify({ status: "succeeded", counts: { documents: 2 } }), stderr: "" }));
|
||||||
@@ -219,6 +278,7 @@ test("complete preprocessing snapshots Catalog metadata and commits its PostgreS
|
|||||||
9,
|
9,
|
||||||
"sha256:" + "f".repeat(64),
|
"sha256:" + "f".repeat(64),
|
||||||
{ status: "succeeded" },
|
{ status: "succeeded" },
|
||||||
|
expect.any(String),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -257,6 +317,7 @@ test("preprocessing records a failed PostgreSQL state when its hidden worker fai
|
|||||||
9,
|
9,
|
||||||
"sha256:" + "f".repeat(64),
|
"sha256:" + "f".repeat(64),
|
||||||
{ status: "failed", errorCode: "schema_index_failed" },
|
{ status: "failed", errorCode: "schema_index_failed" },
|
||||||
|
expect.any(String),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -273,6 +334,7 @@ test("semantic preflight failure is persisted before returning", async () => {
|
|||||||
9,
|
9,
|
||||||
"sha256:" + "f".repeat(64),
|
"sha256:" + "f".repeat(64),
|
||||||
{ status: "failed", errorCode: "semantic_index_incompatible" },
|
{ status: "failed", errorCode: "semantic_index_incompatible" },
|
||||||
|
expect.any(String),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -310,6 +372,7 @@ test("clear invalidates Catalog readiness before clearing only derived worker da
|
|||||||
expect(runChild).toHaveBeenCalledWith({
|
expect(runChild).toHaveBeenCalledWith({
|
||||||
argv: ["preprocess", "clear", "--json", "-c", "/dev/fd/3"],
|
argv: ["preprocess", "clear", "--json", "-c", "/dev/fd/3"],
|
||||||
configPath: expect.any(String),
|
configPath: expect.any(String),
|
||||||
|
guard: { lockPath: expect.any(String), tokenPath: expect.any(String), token: expect.stringMatching(/^[a-f0-9]{64}$/) },
|
||||||
});
|
});
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
status: "succeeded",
|
status: "succeeded",
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ services:
|
|||||||
test:
|
test:
|
||||||
- CMD-SHELL
|
- CMD-SHELL
|
||||||
- >-
|
- >-
|
||||||
pg_isready -U thothii_catalog_migrate -d thothii_catalog
|
pg_isready -h 127.0.0.1 -U thothii_catalog_migrate -d thothii_catalog
|
||||||
&& test "$(psql -U thothii_catalog_migrate -d thothii_catalog -Atqc
|
&& test "$(psql -U thothii_catalog_migrate -d thothii_catalog -Atqc
|
||||||
"select count(*) from pg_catalog.pg_roles where rolname = 'thothii_catalog_runtime'")" = "1"
|
"select count(*) from pg_catalog.pg_roles where rolname = 'thothii_catalog_runtime'")" = "1"
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ cp deploy/secrets/thothii.secrets.example deploy/secrets/thothii.secrets
|
|||||||
chmod 600 deploy/secrets/thothii.secrets
|
chmod 600 deploy/secrets/thothii.secrets
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For a normal local installation, `tht setup --complete` creates the active bundle at
|
||||||
|
`deploy/local/secrets/thothii.secrets` and creates the two Catalog password files beside it. The
|
||||||
|
generated `deploy/local/operator.env` contains only absolute paths to those files; never copy
|
||||||
|
secret values into `operator.env`.
|
||||||
|
|
||||||
The file uses strict `KEY=VALUE` lines (comments and blank lines are allowed). The supported
|
The file uses strict `KEY=VALUE` lines (comments and blank lines are allowed). The supported
|
||||||
installation keys are `THT_MODEL_API_KEY`, `THT_DWH_API_KEY`, `THT_CA`, `THT_SSL_CA`,
|
installation keys are `THT_MODEL_API_KEY`, `THT_DWH_API_KEY`, `THT_CA`, `THT_SSL_CA`,
|
||||||
`THT_OIDC_CLIENT_SECRET`, and `THT_AUTHENTIK_API_TOKEN`. Installation Model Catalog providers may
|
`THT_OIDC_CLIENT_SECRET`, and `THT_AUTHENTIK_API_TOKEN`. Installation Model Catalog providers may
|
||||||
@@ -29,6 +34,11 @@ Session and metadata-generation runtimes read only the provider key named by
|
|||||||
credential reference, not their execution lifecycle. Pi-owned authentication remains available only
|
credential reference, not their execution lifecycle. Pi-owned authentication remains available only
|
||||||
to session-only built-in providers through `authentication.mode: pi_auth`.
|
to session-only built-in providers through `authentication.mode: pi_auth`.
|
||||||
|
|
||||||
|
Workspace database credentials are intentionally not part of this global bundle. Configure each
|
||||||
|
workspace's database binding, password/token, tunnel key and CA in Database Management; the
|
||||||
|
installation stores those values in its encrypted workspace secret store. The workspace Git
|
||||||
|
repository may declare database identity and Evidence, but must never contain these credentials.
|
||||||
|
|
||||||
Do not add vector or embedding endpoint credentials to the bundle. Active operator manuals use
|
Do not add vector or embedding endpoint credentials to the bundle. Active operator manuals use
|
||||||
internal Qdrant and Ollama services, so vector/embedding runtime endpoint secrets are not part of
|
internal Qdrant and Ollama services, so vector/embedding runtime endpoint secrets are not part of
|
||||||
the supported installation contract.
|
the supported installation contract.
|
||||||
|
|||||||
@@ -96,10 +96,15 @@ deve invece contenere `mode` e `defaultLocale`, altrimenti viene rifiutato.
|
|||||||
## Lingua, continuità e dati
|
## Lingua, continuità e dati
|
||||||
|
|
||||||
La lingua UI traduce il testo dell'applicazione, non i contenuti di dominio.
|
La lingua UI traduce il testo dell'applicazione, non i contenuti di dominio.
|
||||||
Alla creazione, la lingua UI viene acquisita come `interactionLanguage`; il
|
Alla creazione, la lingua UI viene acquisita come `interactionLanguage` di ripiego.
|
||||||
manifest salva `interaction_language`, che governa domande e scelte del modello.
|
Il CLI riconosce la lingua della domanda originale e salva `interaction_language`
|
||||||
|
nel manifest; usa il ripiego solo per input troppo brevi, ambigui o composti da codice.
|
||||||
|
Questa lingua governa domande, spiegazioni, scelte e controlli HITL. Il gate la
|
||||||
|
include nei descrittori e il frontend la applica al sottoalbero dei widget,
|
||||||
|
senza cambiare la lingua della navigazione.
|
||||||
Alla ripresa vale la lingua salvata, non l'ultima scelta dell'header. Per i manifest
|
Alla ripresa vale la lingua salvata, non l'ultima scelta dell'header. Per i manifest
|
||||||
precedenti senza campo viene fissata la lingua workspace disponibile alla prima ripresa.
|
precedenti senza campo viene riconosciuta e fissata la lingua della domanda,
|
||||||
|
con la lingua workspace disponibile alla prima ripresa come ripiego.
|
||||||
|
|
||||||
Il cambio lingua Omics invia il form Django e ricarica la pagina. ThothII conserva
|
Il cambio lingua Omics invia il form Django e ricarica la pagina. ThothII conserva
|
||||||
solo l'ID della selezione in `sessionStorage`, separato per pathname, issuer e
|
solo l'ID della selezione in `sessionStorage`, separato per pathname, issuer e
|
||||||
|
|||||||
@@ -81,20 +81,20 @@ The model proposes; a human reviewer decides at gates through widgets:
|
|||||||
|
|
||||||
The frontend renders these widget descriptors (registry in `src/widgets/`). It rebuilds the live transcript in memory from the SSE stream (`src/store/sessionStore.ts`); it is **not persisted**.
|
The frontend renders these widget descriptors (registry in `src/widgets/`). It rebuilds the live transcript in memory from the SSE stream (`src/store/sessionStore.ts`); it is **not persisted**.
|
||||||
|
|
||||||
## Curated and immutable Evidence
|
## Evidence sources, local authority and search projections
|
||||||
|
|
||||||
The workspace repository is the publication boundary. The curator prepares `evidence/source/`,
|
The workspace repository publishes revision-pinned workspace identities and Evidence sources.
|
||||||
reviews units in `evidence/curated/`, validates them, and merges them. With `evidence.schema_version: 2`,
|
An initialized editable Evidence archive is maintained locally through external editors and
|
||||||
the runtime materializes the full `evidence/` tree from the exact Git commit, but the renderer passes
|
explicit consolidation; normal preprocessing or source refresh must not overwrite its manual
|
||||||
only `curated/**/*.md` from the immutable revision root to preprocessing. Sources, manifests, and
|
corrections. File save, active search generation and a later human Git commit/push are separate
|
||||||
evaluation data remain available for traceability. The runtime never modifies, stages, commits, or
|
outcomes. See [the current Evidence contract](../contracts/curated-evidence-v4.md) and
|
||||||
publishes the authoring repository.
|
[source/publication boundaries](../contracts/workspace-evidence-v3.md).
|
||||||
|
|
||||||
Before indexing, the curated corpus from the pinned revision is validated. Each workspace has two
|
Each workspace has separate Qdrant collections. `reference` contains Schema, relationships and
|
||||||
physical Qdrant collections with different lifecycles. `reference` contains Schema, relationships,
|
Evidence and may be replaced or cleared by preprocessing. Memory uses its own dense/BM25
|
||||||
and Evidence and may be replaced or cleared by preprocessing; `memory` contains `memory` and
|
projection, rebuilt from authoritative PostgreSQL cards rather than old vector payloads or
|
||||||
`solved_question` records and is never preprocessing output. Only the `reference` collection has the
|
session artifacts. Both collections can contain sparse vectors; their ownership and cleanup
|
||||||
sparse `bm25` vector with `idf`, and only the Evidence stage writes sparse values.
|
lifecycles remain separate. See [Memory](../gestione-memory.md).
|
||||||
|
|
||||||
The Administration control can clear the replaceable reference collection, LSH, corpus, and derived
|
The Administration control can clear the replaceable reference collection, LSH, corpus, and derived
|
||||||
checkpoints. The operation preserves the memory collection and makes preprocessing required before
|
checkpoints. The operation preserves the memory collection and makes preprocessing required before
|
||||||
@@ -115,6 +115,13 @@ the core can admit a new session.
|
|||||||
|
|
||||||
## Runtime composition
|
## Runtime composition
|
||||||
|
|
||||||
|
PostgreSQL is the current database-metadata authority for all core consumers, not a deferred
|
||||||
|
catalog-to-core integration. The historical research on a separate catalog service and
|
||||||
|
`annotations.yaml` publication is superseded by ADRs 0004 and 0016. Preserve read-only DWH access,
|
||||||
|
installation-local bindings/secrets, revision-pinned workspace identity, and fail-closed readiness
|
||||||
|
when changing those boundaries. The exact snapshot interface is the
|
||||||
|
[Catalog Schema Snapshot contract](../contracts/catalog-schema-snapshot.md).
|
||||||
|
|
||||||
The local stack is started by `./scripts/run-stack.sh` after the installation descriptor and
|
The local stack is started by `./scripts/run-stack.sh` after the installation descriptor and
|
||||||
`deploy/env/local.env` exist. `core` includes Pi. `catalog-db`, Qdrant, and the Ollama embedding
|
`deploy/env/local.env` exist. `core` includes Pi. `catalog-db`, Qdrant, and the Ollama embedding
|
||||||
service are internal Compose services; only the DWH and model-provider endpoint remain external.
|
service are internal Compose services; only the DWH and model-provider endpoint remain external.
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 189 KiB |
|
Before Width: | Height: | Size: 186 KiB |
@@ -1,32 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<title>Archify automated browser evidence · thothii-core-sequence.html</title>
|
|
||||||
<style>
|
|
||||||
*{box-sizing:border-box}body{margin:0;padding:24px;background:#e9eef5;color:#172033;font:14px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}header{max-width:1500px;margin:0 auto 18px}h1{margin:0 0 6px;font-size:20px}p{margin:0;color:#526176}.grid{max-width:1500px;margin:auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}figure{margin:0;padding:10px;background:white;border:1px solid #c9d4e3;border-radius:12px;box-shadow:0 10px 30px rgba(15,23,42,.08)}img{display:block;width:100%;height:auto;border:1px solid #e2e8f0}figcaption{padding:9px 4px 2px;color:#526176}@media(max-width:900px){.grid{grid-template-columns:1fr}}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header><h1>Automated browser evidence</h1><p>thothii-core-sequence.html · visual-check containment pass · perceptual visual review pending</p></header>
|
|
||||||
<main class="grid">
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-core-sequence.visual-check.1440x900.light.png" alt="light 1440 by 900">
|
|
||||||
<figcaption><strong>LIGHT</strong> · 1440×900 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-core-sequence.visual-check.1440x900.dark.png" alt="dark 1440 by 900">
|
|
||||||
<figcaption><strong>DARK</strong> · 1440×900 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-core-sequence.visual-check.2048x1320.light.png" alt="light 2048 by 1320">
|
|
||||||
<figcaption><strong>LIGHT</strong> · 2048×1320 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-core-sequence.visual-check.2048x1320.dark.png" alt="dark 2048 by 1320">
|
|
||||||
<figcaption><strong>DARK</strong> · 2048×1320 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,548 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"ok": true,
|
|
||||||
"command": "visual-check",
|
|
||||||
"evidenceKind": "automated-browser",
|
|
||||||
"status": "pass",
|
|
||||||
"visualReview": "pending",
|
|
||||||
"artifact": {
|
|
||||||
"path": "/Users/mp/projects/ThothII/docs/architecture/thothii-core-sequence.html",
|
|
||||||
"sha256": "b521eb942f7889cfc3a5e29010546ba59eeab1cf485c22c533d271ccef9a28d5",
|
|
||||||
"bytes": 716881
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"detail": "read",
|
|
||||||
"motion": "still"
|
|
||||||
},
|
|
||||||
"chrome": {
|
|
||||||
"status": "available",
|
|
||||||
"executable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
||||||
},
|
|
||||||
"diagnostics": [],
|
|
||||||
"containment": {
|
|
||||||
"status": "pass",
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1194,
|
|
||||||
"diagramWidth": 1164,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1242,
|
|
||||||
"diagramWidth": 1212,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1402,
|
|
||||||
"diagramWidth": 1372,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1818,
|
|
||||||
"diagramWidth": 1768,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"readability": {
|
|
||||||
"status": "pass",
|
|
||||||
"minimumProjectedNodeTextPx": 6,
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1194,
|
|
||||||
"diagramWidth": 1164,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1242,
|
|
||||||
"diagramWidth": 1212,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1402,
|
|
||||||
"diagramWidth": 1372,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1818,
|
|
||||||
"diagramWidth": 1768,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"viewerChrome": {
|
|
||||||
"status": "pass",
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1194,
|
|
||||||
"diagramWidth": 1164,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1242,
|
|
||||||
"diagramWidth": 1212,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1402,
|
|
||||||
"diagramWidth": 1372,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1818,
|
|
||||||
"diagramWidth": 1768,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"captures": {
|
|
||||||
"status": "pass",
|
|
||||||
"screenshots": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1194,
|
|
||||||
"diagramWidth": 1164,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light",
|
|
||||||
"file": "thothii-core-sequence.visual-check.1440x900.light.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "dark",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1194,
|
|
||||||
"diagramWidth": 1164,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "dark",
|
|
||||||
"file": "thothii-core-sequence.visual-check.1440x900.dark.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1818,
|
|
||||||
"diagramWidth": 1768,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light",
|
|
||||||
"file": "thothii-core-sequence.visual-check.2048x1320.light.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "dark",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1818,
|
|
||||||
"diagramWidth": 1768,
|
|
||||||
"viewBoxWidth": 1080,
|
|
||||||
"minimumProjectedNodeTextPx": 7,
|
|
||||||
"minimumProjectedNodeText": "browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "dark",
|
|
||||||
"file": "thothii-core-sequence.visual-check.2048x1320.dark.png"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contactSheet": "thothii-core-sequence.visual-check.html"
|
|
||||||
},
|
|
||||||
"sidecars": {
|
|
||||||
"receipt": "thothii-core-sequence.visual-check.json",
|
|
||||||
"contactSheet": "thothii-core-sequence.visual-check.html"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 137 KiB |
|
Before Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 182 KiB |
@@ -1,32 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<title>Archify automated browser evidence · thothii-runtime.html</title>
|
|
||||||
<style>
|
|
||||||
*{box-sizing:border-box}body{margin:0;padding:24px;background:#e9eef5;color:#172033;font:14px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}header{max-width:1500px;margin:0 auto 18px}h1{margin:0 0 6px;font-size:20px}p{margin:0;color:#526176}.grid{max-width:1500px;margin:auto;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}figure{margin:0;padding:10px;background:white;border:1px solid #c9d4e3;border-radius:12px;box-shadow:0 10px 30px rgba(15,23,42,.08)}img{display:block;width:100%;height:auto;border:1px solid #e2e8f0}figcaption{padding:9px 4px 2px;color:#526176}@media(max-width:900px){.grid{grid-template-columns:1fr}}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header><h1>Automated browser evidence</h1><p>thothii-runtime.html · visual-check containment pass · perceptual visual review pending</p></header>
|
|
||||||
<main class="grid">
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-runtime.visual-check.1440x900.light.png" alt="light 1440 by 900">
|
|
||||||
<figcaption><strong>LIGHT</strong> · 1440×900 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-runtime.visual-check.1440x900.dark.png" alt="dark 1440 by 900">
|
|
||||||
<figcaption><strong>DARK</strong> · 1440×900 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-runtime.visual-check.2048x1320.light.png" alt="light 2048 by 1320">
|
|
||||||
<figcaption><strong>LIGHT</strong> · 2048×1320 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
<figure>
|
|
||||||
<img src="thothii-runtime.visual-check.2048x1320.dark.png" alt="dark 2048 by 1320">
|
|
||||||
<figcaption><strong>DARK</strong> · 2048×1320 · containment pass</figcaption>
|
|
||||||
</figure>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,548 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"ok": true,
|
|
||||||
"command": "visual-check",
|
|
||||||
"evidenceKind": "automated-browser",
|
|
||||||
"status": "pass",
|
|
||||||
"visualReview": "pending",
|
|
||||||
"artifact": {
|
|
||||||
"path": "/Users/mp/projects/ThothII/docs/architecture/thothii-runtime.html",
|
|
||||||
"sha256": "ad19195852c7c643228663e5bf7f3cb273afb0456fedbe295d4df24bc345b6c7",
|
|
||||||
"bytes": 724277
|
|
||||||
},
|
|
||||||
"state": {
|
|
||||||
"detail": "read",
|
|
||||||
"motion": "still"
|
|
||||||
},
|
|
||||||
"chrome": {
|
|
||||||
"status": "available",
|
|
||||||
"executable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
||||||
},
|
|
||||||
"diagnostics": [],
|
|
||||||
"containment": {
|
|
||||||
"status": "pass",
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 968,
|
|
||||||
"diagramWidth": 938,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.20735294117647,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1009,
|
|
||||||
"diagramWidth": 979,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.478676470588235,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1172,
|
|
||||||
"diagramWidth": 1142,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 7.557352941176471,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1583,
|
|
||||||
"diagramWidth": 1533,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 9,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"readability": {
|
|
||||||
"status": "pass",
|
|
||||||
"minimumProjectedNodeTextPx": 6,
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 968,
|
|
||||||
"diagramWidth": 938,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.20735294117647,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1009,
|
|
||||||
"diagramWidth": 979,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.478676470588235,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1172,
|
|
||||||
"diagramWidth": 1142,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 7.557352941176471,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1583,
|
|
||||||
"diagramWidth": 1533,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 9,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"viewerChrome": {
|
|
||||||
"status": "pass",
|
|
||||||
"viewports": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 968,
|
|
||||||
"diagramWidth": 938,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.20735294117647,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1600,
|
|
||||||
"height": 1000,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1600,
|
|
||||||
"innerHeight": 1000,
|
|
||||||
"scrollWidth": 1600,
|
|
||||||
"scrollHeight": 1000,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1009,
|
|
||||||
"diagramWidth": 979,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.478676470588235,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1920,
|
|
||||||
"height": 1080,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1920,
|
|
||||||
"innerHeight": 1080,
|
|
||||||
"scrollWidth": 1920,
|
|
||||||
"scrollHeight": 1080,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1172,
|
|
||||||
"diagramWidth": 1142,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 7.557352941176471,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1583,
|
|
||||||
"diagramWidth": 1533,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 9,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"captures": {
|
|
||||||
"status": "pass",
|
|
||||||
"screenshots": [
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 968,
|
|
||||||
"diagramWidth": 938,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.20735294117647,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light",
|
|
||||||
"file": "thothii-runtime.visual-check.1440x900.light.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 1440,
|
|
||||||
"height": 900,
|
|
||||||
"theme": "dark",
|
|
||||||
"innerWidth": 1440,
|
|
||||||
"innerHeight": 900,
|
|
||||||
"scrollWidth": 1440,
|
|
||||||
"scrollHeight": 900,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 968,
|
|
||||||
"diagramWidth": 938,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 6.20735294117647,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 51,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "dark",
|
|
||||||
"file": "thothii-runtime.visual-check.1440x900.dark.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "light",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1583,
|
|
||||||
"diagramWidth": 1533,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 9,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "light",
|
|
||||||
"file": "thothii-runtime.visual-check.2048x1320.light.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"width": 2048,
|
|
||||||
"height": 1320,
|
|
||||||
"theme": "dark",
|
|
||||||
"innerWidth": 2048,
|
|
||||||
"innerHeight": 1320,
|
|
||||||
"scrollWidth": 2048,
|
|
||||||
"scrollHeight": 1320,
|
|
||||||
"overflowX": false,
|
|
||||||
"overflowY": false,
|
|
||||||
"ok": true,
|
|
||||||
"readerWidth": 1583,
|
|
||||||
"diagramWidth": 1533,
|
|
||||||
"viewBoxWidth": 1360,
|
|
||||||
"minimumProjectedNodeTextPx": 9,
|
|
||||||
"minimumProjectedNodeText": "Browser",
|
|
||||||
"minimumProjectedNodeTextDetail": "context",
|
|
||||||
"minimumRequiredNodeTextPx": 6,
|
|
||||||
"readabilityOk": true,
|
|
||||||
"hasLegend": true,
|
|
||||||
"hasNavigationDock": true,
|
|
||||||
"legendDockIntersectionArea": 0,
|
|
||||||
"dockStageIntersectionArea": 0,
|
|
||||||
"dockStageGap": 10.21875,
|
|
||||||
"requiredDockStageGap": 10,
|
|
||||||
"viewerChromeStageOk": true,
|
|
||||||
"viewerChromeReserve": 41,
|
|
||||||
"viewerChromeActive": true,
|
|
||||||
"viewerChromeOk": true,
|
|
||||||
"resolvedTheme": "dark",
|
|
||||||
"file": "thothii-runtime.visual-check.2048x1320.dark.png"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contactSheet": "thothii-runtime.visual-check.html"
|
|
||||||
},
|
|
||||||
"sidecars": {
|
|
||||||
"receipt": "thothii-runtime.visual-check.json",
|
|
||||||
"contactSheet": "thothii-runtime.visual-check.html"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -244,5 +244,5 @@ The first installed consolidation performs this conversion automatically when th
|
|||||||
legacy manifest is present, then validates and activates the result. Preserve the
|
legacy manifest is present, then validates and activates the result. Preserve the
|
||||||
existing checkout in backups before upgrading. The E1 validation used an isolated
|
existing checkout in backups before upgrading. The E1 validation used an isolated
|
||||||
copy; E2 also converted and indexed all 35 units on the running local preview.
|
copy; E2 also converted and indexed all 35 units on the running local preview.
|
||||||
See the [E1 validation report](../plans/2026-09-09-evidence-e1-validation.md) and
|
See the [E1 validation report](../reports/knowledge-archives-release.md) and
|
||||||
[E2 validation report](../plans/2026-09-09-evidence-e2-validation.md).
|
[E2 validation report](../reports/knowledge-archives-release.md).
|
||||||
|
|||||||
@@ -153,6 +153,30 @@ Core admission requires all of the following:
|
|||||||
Failure leaves the workspace unavailable to the core. There is no rollback: fix the cause and run
|
Failure leaves the workspace unavailable to the core. There is no rollback: fix the cause and run
|
||||||
the complete command again.
|
the complete command again.
|
||||||
|
|
||||||
|
## Interrupted owner recovery
|
||||||
|
|
||||||
|
Current preprocessing runs also hold a kernel writer lock on the shared workspace
|
||||||
|
volume. Every mutating worker inherits a separate shared kernel lock and validates
|
||||||
|
an owner generation before starting. Recovery takes both locks exclusively before
|
||||||
|
rotating that generation: a surviving orphan worker blocks recovery, while a delayed
|
||||||
|
worker from the old generation cannot start. These guards establish process ownership;
|
||||||
|
PostgreSQL remains the readiness authority.
|
||||||
|
|
||||||
|
A repeated `preprocess run` can mark an orphaned current-protocol Catalog lease as
|
||||||
|
`preprocessing_interrupted` through the version/fingerprint/run-identity-checked completion
|
||||||
|
operation, then restart the entire pipeline. It does not resume internal stages or
|
||||||
|
clear Memory, sessions, curated descriptions or canonical Evidence. Older running jobs
|
||||||
|
without this ownership protocol are not automatically adopted; inspect their original
|
||||||
|
owner during upgrade instead of deleting data or resetting leases speculatively.
|
||||||
|
Each attempt records its unique run identity in PostgreSQL (migration 015). A late
|
||||||
|
completion from the previous attempt cannot finish its replacement, even when the
|
||||||
|
metadata revision and input fingerprint are unchanged.
|
||||||
|
|
||||||
|
The installer requests this guarded recovery when status remains running. An active
|
||||||
|
owner returns a conflict and the installer waits. A pending destructive Catalog Sync
|
||||||
|
Run is preserved for human review, including when its reservation temporarily blocks
|
||||||
|
binding import. Interrupted synchronization is retried through the existing domain API.
|
||||||
|
|
||||||
## Administration sidebar
|
## Administration sidebar
|
||||||
|
|
||||||
The Administration sidebar exposes the same one-shot operation for the workspace selected in the
|
The Administration sidebar exposes the same one-shot operation for the workspace selected in the
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ This page describes the complete workspace Evidence lifecycle: where original ma
|
|||||||
|
|
||||||
## Editable local Evidence
|
## Editable local Evidence
|
||||||
|
|
||||||
E1 adds [Curated Evidence v4 and a persistent local archive](contracts/curated-evidence-v4.md).
|
E1 adds [Curated Evidence v4 and a persistent local archive](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/curated-evidence-v4.md).
|
||||||
The visible title and payload fields are authoritative Markdown. New manual units need no
|
The visible title and payload fields are authoritative Markdown. New manual units need no
|
||||||
external source; consolidation records their curator and distinguishes later corrections
|
external source; consolidation records their curator and distinguishes later corrections
|
||||||
from original documentary provenance. The core archive API creates immutable candidates
|
from original documentary provenance. The core archive API creates immutable candidates
|
||||||
@@ -14,12 +14,12 @@ E2 adds **Administration → Evidence management**, actual host file paths, comp
|
|||||||
browsing and filtering, and the installed `tht workspace evidence consolidate
|
browsing and filtering, and the installed `tht workspace evidence consolidate
|
||||||
--workspace <id>` command. Edit files externally, consolidate to activate them, then
|
--workspace <id>` command. Edit files externally, consolidate to activate them, then
|
||||||
review and run Git manually. Runtime consumes only the active local snapshot.
|
review and run Git manually. Runtime consumes only the active local snapshot.
|
||||||
The [v4 contract](contracts/curated-evidence-v4.md#administration-and-installed-command)
|
The [v4 contract](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/curated-evidence-v4.md#administration-and-installed-command)
|
||||||
describes host mounting, first conversion, failure recovery and Clear behavior.
|
describes host mounting, first conversion, failure recovery and Clear behavior.
|
||||||
The local PSD preview has 35 converted and indexed units. E3 adds explicit import/refresh
|
The local PSD preview has 35 converted and indexed units. E3 adds explicit import/refresh
|
||||||
from local drafts and configured HTTP/S3 sources, durable current/proposed comparisons,
|
from local drafts and configured HTTP/S3 sources, durable current/proposed comparisons,
|
||||||
and keep/replace decisions with activation and retry. See
|
and keep/replace decisions with activation and retry. See
|
||||||
[Import drafts and refresh sources](contracts/curated-evidence-v4.md#import-drafts-and-refresh-sources).
|
[Import drafts and refresh sources](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/curated-evidence-v4.md#import-drafts-and-refresh-sources).
|
||||||
Workflow gate corrections remain the subsequent shared increment, X1.
|
Workflow gate corrections remain the subsequent shared increment, X1.
|
||||||
|
|
||||||
## Existing repository publication path
|
## Existing repository publication path
|
||||||
@@ -92,7 +92,7 @@ Join orders using the order number, financial year and company.
|
|||||||
|
|
||||||
Use `tht evidence migrate <workspace-root>` for deterministic legacy conversion. The
|
Use `tht evidence migrate <workspace-root>` for deterministic legacy conversion. The
|
||||||
conversion preserves typed content and initializes an archive baseline; it does not
|
conversion preserves typed content and initializes an archive baseline; it does not
|
||||||
activate the local corpus. See the [v4 contract](contracts/curated-evidence-v4.md) for
|
activate the local corpus. See the [v4 contract](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/curated-evidence-v4.md) for
|
||||||
all eight kinds, provenance, file layout and the E1/E2 boundary.
|
all eight kinds, provenance, file layout and the E1/E2 boundary.
|
||||||
|
|
||||||
## Legacy v3 representation
|
## Legacy v3 representation
|
||||||
@@ -262,5 +262,5 @@ Formulas use a format distinct from document Evidence. A formula proposed during
|
|||||||
|
|
||||||
## Contract references
|
## Contract references
|
||||||
|
|
||||||
- [Workspace Evidence v3 contract](contracts/workspace-evidence-v3.md)
|
- [Workspace Evidence v3 contract](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/workspace-evidence-v3.md)
|
||||||
- [Preprocessing CLI contract](contracts/workspace-preprocessing-cli.md)
|
- [Preprocessing CLI contract](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/contracts/workspace-preprocessing-cli.md)
|
||||||
|
|||||||
@@ -128,6 +128,51 @@ endpoint expects a model name different from the catalog key.
|
|||||||
Provider integrations remain declarative. Do not register providers from
|
Provider integrations remain declarative. Do not register providers from
|
||||||
`harness/.pi/extensions/`; those extensions implement the workflow and human gates only.
|
`harness/.pi/extensions/`; those extensions implement the workflow and human gates only.
|
||||||
|
|
||||||
|
### Qwen 3.6 sessions and thinking controls
|
||||||
|
|
||||||
|
For Qwen served through a vLLM-compatible chat template, declare the following inside the
|
||||||
|
model's `session` block, alongside its context and output limits:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
reasoning: true
|
||||||
|
compatibility:
|
||||||
|
supportsDeveloperRole: false
|
||||||
|
supportsReasoningEffort: false
|
||||||
|
supportsStore: false
|
||||||
|
maxTokensField: max_tokens
|
||||||
|
thinkingFormat: qwen-chat-template
|
||||||
|
```
|
||||||
|
|
||||||
|
This makes Pi send `chat_template_kwargs.enable_thinking` from the selected thinking level,
|
||||||
|
with `preserve_thinking: true`. Choose **off** to explicitly disable thinking. The alternative
|
||||||
|
`thinkingFormat: qwen` is for endpoints expecting top-level `enable_thinking`. Both formats
|
||||||
|
require `reasoning: true`; declaring `reasoning: false` does not tell the server to disable
|
||||||
|
thinking. Omit `thinkingFormat` to preserve Pi's default behavior for other providers.
|
||||||
|
|
||||||
|
Regenerate projections with the updated host CLI and recreate the local core container after
|
||||||
|
rebuilding it. Do not add these fields directly to generated Pi files. These controls do not
|
||||||
|
force tool calls or certify the workflow; perform the operator verification above.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml installation generate
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the model identifier exposed by your endpoint, such as `qwen3.6-35b-a3b`, and limits
|
||||||
|
supported by that deployment. The thinking format configures the Pi session adapter;
|
||||||
|
metadata generation continues to use its separate LiteLLM settings.
|
||||||
|
|
||||||
|
If a session displays text such as `{"type":"bash","command":"tht session show … --json"}`
|
||||||
|
and never opens a review widget, that text is not an executed tool call. A verified cause
|
||||||
|
was the Evidence JSON extension being loaded into interactive sessions and forcing
|
||||||
|
`response_format: {type: "json_object"}`. Upgrade to the core image containing the fix:
|
||||||
|
the extension belongs in `.pi/evidence-extensions/` and is loaded explicitly only by
|
||||||
|
Evidence authoring. It must not also remain in the automatically loaded `.pi/extensions/`
|
||||||
|
directory. Regenerating model configuration alone does not remove an extension from an old image.
|
||||||
|
|
||||||
|
After upgrading, reload the browser and resume the session. Verify that Pi executes
|
||||||
|
`tht session show` and opens a review widget. This fix does not require changing the Qwen
|
||||||
|
server, forcing every turn to call a tool, or teaching the model to print tool-call JSON.
|
||||||
|
|
||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
Every provider chooses one explicit mode:
|
Every provider chooses one explicit mode:
|
||||||
|
|||||||
@@ -226,5 +226,5 @@ error. Preparation is repeatable and checks migration checksums.
|
|||||||
See [the M1 specification](plans/2026-09-08-memory-m1-spec.md) and
|
See [the M1 specification](plans/2026-09-08-memory-m1-spec.md) and
|
||||||
[ADR 0018](adr/0018-use-postgres-for-memory-and-qdrant-for-retrieval.md) for the
|
[ADR 0018](adr/0018-use-postgres-for-memory-and-qdrant-for-retrieval.md) for the
|
||||||
approved scope and acceptance boundaries.
|
approved scope and acceptance boundaries.
|
||||||
See [M2 implementation and validation](plans/2026-09-09-memory-m2-validation.md)
|
See [M2 implementation and validation](reports/knowledge-archives-release.md)
|
||||||
for the retrieval checks and real embedding test command.
|
for the retrieval checks and real embedding test command.
|
||||||
|
|||||||
@@ -90,4 +90,4 @@ happen from the workflow’s point of view.
|
|||||||
session does not become Evidence automatically: a curator must review and publish it in Git.
|
session does not become Evidence automatically: a curator must review and publish it in Git.
|
||||||
- For login and access recovery, use [local authentication](install/authentication-local.md) or
|
- For login and access recovery, use [local authentication](install/authentication-local.md) or
|
||||||
[OIDC authentication](install/authentication-oidc.md) for full, or contact the
|
[OIDC authentication](install/authentication-oidc.md) for full, or contact the
|
||||||
portal administrator for [embedded/upstream access](install/authentication-upstream.md).
|
portal administrator for [embedded/upstream access](install/shell-and-language.md).
|
||||||
|
|||||||
@@ -1,34 +1,33 @@
|
|||||||
# ThothII documentation
|
# ThothII documentation
|
||||||
|
|
||||||
ThothII is a human-reviewed datamart builder. It turns a question into validated SQL through an
|
ThothII turns a natural-language question into reviewed SQL. The model proposes;
|
||||||
eight-phase workflow: the model proposes; a reviewer makes the decisions that are persisted.
|
a human reviewer decides which interpretations, sources and results to accept.
|
||||||
|
|
||||||
Start with the path that matches the work you need to do:
|
This is the public product manual. Start with the task you need to perform:
|
||||||
|
|
||||||
| I need to… | Start here |
|
| I need to… | Start here |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Install or operate one instance | [Install and first start](install/first-start.md) |
|
| Understand the product and its boundaries | [What ThothII does](product-overview.md) |
|
||||||
| Upgrade the server and integrate Omics Portal | [Codex server handoff](operations/server-codex-handoff.md) |
|
| Install on Mac, Windows through WSL2, or Linux | [Italian procedure](install/standalone-manual-it.md) · [English procedure](install/standalone-manual-en.md) |
|
||||||
| Choose full/embedded and configure the shell | [Shell and localization](operations/shell-and-localization.md) |
|
| Choose display mode and language | [Display mode and language](install/shell-and-language.md) |
|
||||||
| Reuse an authenticated server portal without a second login | [Upstream authentication](install/authentication-upstream.md) |
|
| Configure login | [Local accounts](install/authentication-local.md) · [OIDC](install/authentication-oidc.md) |
|
||||||
| Understand how the two renderings share the same application | [Rendering architecture](architecture/application-shell.md) |
|
| Configure model providers | [Model configuration](general/pi-configuration.md) |
|
||||||
| Validate login, logout and portal integration before release | [Acceptance matrix](testing/authentication-manual-acceptance.md) |
|
| Prepare a domain workspace | [Workspaces](operations/workspaces.md) |
|
||||||
| Add, update, or prepare a workspace | [Workspace operations](operations/workspaces.md) |
|
| Configure databases and reviewed descriptions | [Database management](operations/database-management.md) |
|
||||||
| Ask a question and review the SQL workflow | [User guide](guida-utente.md) |
|
| Ask a question and review SQL | [User guide](guida-utente.md) · [Workflow](skills.md) |
|
||||||
| Configure and refresh an authoritative database catalog | [Database management](operations/database-management.md) |
|
| Maintain domain knowledge | [Evidence](evidence.md) · [Memory](usage/memory.md) |
|
||||||
| Author and publish domain Evidence | [Evidence](evidence.md) |
|
|
||||||
| Understand boundaries and persistence | [Architecture overview](architecture/overview.md) |
|
|
||||||
|
|
||||||
## How the documentation is organised
|
## Scope of this manual
|
||||||
|
|
||||||
- **Install and operate** documents host-side setup, authentication, lifecycle, workspaces, and
|
The manual covers the product, installation, use and administration. Architecture,
|
||||||
Pi administration.
|
code contracts, design decisions, implementation plans, test reports and site-specific
|
||||||
- **Use ThothII** documents the two application paths: reviewed NL→SQL sessions and administrative
|
deployment handoffs are developer/project material maintained in the repository;
|
||||||
database management.
|
they are not pages of this site and are not included in its search index.
|
||||||
- **Architecture and contracts** explain why the system behaves as it does and define the
|
|
||||||
machine-facing boundaries. Consult them when integrating or changing an implementation; they
|
|
||||||
are not a substitute for an operator runbook.
|
|
||||||
|
|
||||||
The host-side `tht` command is the operator interface. The Python `tht` inside `harness/` is a
|
The installation procedures distinguish checked documentation from platform and
|
||||||
different, internal workflow CLI invoked by the core. In examples, use an absolute installation
|
functional tests that still require execution. A clone does not transfer another
|
||||||
descriptor path whenever discovery is not unambiguous.
|
installation's credentials, data or network access.
|
||||||
|
|
||||||
|
The host-side `tht` command operates an installation. The Python workflow CLI inside
|
||||||
|
the runtime is a separate internal interface; do not substitute its commands for
|
||||||
|
the host installation procedure.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Use local mode for a standalone PC or Mac, with `shell.mode: full` and
|
Use local mode for a standalone PC or Mac, with `shell.mode: full` and
|
||||||
`shell.defaultLocale: en` in the installation descriptor. Presentation and
|
`shell.defaultLocale: en` in the installation descriptor. Presentation and
|
||||||
authentication are independent: selecting full does not create accounts. Omics
|
authentication are independent: selecting full does not create accounts. Omics
|
||||||
embedded instead uses the [upstream guide](authentication-upstream.md), not local users.
|
embedded instead uses the [upstream guide](shell-and-language.md), not local users.
|
||||||
|
|
||||||
Configure local authentication through `tht`; passwords are entered at an
|
Configure local authentication through `tht`; passwords are entered at an
|
||||||
echo-free prompt or read from a protected `--password-file`, never from a command argument.
|
echo-free prompt or read from a protected `--password-file`, never from a command argument.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Use this guide for **ThothII's own login**, normally `shell.mode: full` on an
|
Use this guide for **ThothII's own login**, normally `shell.mode: full` on an
|
||||||
autonomous server. It is not the integration procedure for an already logged-in
|
autonomous server. It is not the integration procedure for an already logged-in
|
||||||
Omics user. That deployment uses [embedded/upstream](authentication-upstream.md),
|
Omics user. That deployment uses [embedded/upstream](shell-and-language.md),
|
||||||
even when Omics's identity provider is Authentik.
|
even when Omics's identity provider is Authentik.
|
||||||
|
|
||||||
OIDC mode supports a standards-based provider. The browser flow is generic: Authorization Code,
|
OIDC mode supports a standards-based provider. The browser flow is generic: Authorization Code,
|
||||||
@@ -104,7 +104,7 @@ Any authentication failure prevents activation according to the static or live s
|
|||||||
relevant diagnostic surface.
|
relevant diagnostic surface.
|
||||||
|
|
||||||
The complete closed diagnostic-code union and exact role-to-permission expansion are in the
|
The complete closed diagnostic-code union and exact role-to-permission expansion are in the
|
||||||
[authentication architecture](../architecture/authentication.md).
|
[authentication architecture](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/architecture/authentication.md).
|
||||||
|
|
||||||
## Browser login and logout
|
## Browser login and logout
|
||||||
|
|
||||||
@@ -114,4 +114,4 @@ password prompt, but this remains a distinct ThothII login/session, unlike Omics
|
|||||||
upstream. Full's name menu logs out of ThothII only. It does not revoke the
|
upstream. Full's name menu logs out of ThothII only. It does not revoke the
|
||||||
provider session or log out other applications, so a subsequent login can return
|
provider session or log out other applications, so a subsequent login can return
|
||||||
immediately through SSO. No provider token is placed in the UI adapter or browser
|
immediately through SSO. No provider token is placed in the UI adapter or browser
|
||||||
storage. See the [manual acceptance matrix](../testing/authentication-manual-acceptance.md).
|
storage. See the [manual acceptance matrix](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/testing/authentication-manual-acceptance.md).
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ For **embedded in Omics**, retain Omics's existing Authentik authentication and
|
|||||||
configure ThothII as upstream. Omics verifies `datamart_builder.access` and
|
configure ThothII as upstream. Omics verifies `datamart_builder.access` and
|
||||||
administrator status and the proxy supplies the identity; no additional ThothII
|
administrator status and the proxy supplies the identity; no additional ThothII
|
||||||
OIDC client, login or local user is required for that path. Follow the
|
OIDC client, login or local user is required for that path. Follow the
|
||||||
[portal integration guide](authentication-upstream.md).
|
[portal integration guide](shell-and-language.md).
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
|
|||||||
@@ -1,94 +1,63 @@
|
|||||||
# Install and first start
|
# Install and first start
|
||||||
|
|
||||||
This is the supported local installation path. It creates an installation-local configuration and
|
Use the guided procedure for a fresh installation:
|
||||||
starts the Compose stack; it does not create a workspace repository or a database catalog entry.
|
|
||||||
|
|
||||||
## Prerequisites and boundaries
|
- [Italian guided installation](standalone-manual-it.md)
|
||||||
|
- [English guided installation](standalone-manual-en.md)
|
||||||
|
|
||||||
Install Docker Engine with Compose v2, plus the host `tht` command. On macOS or Linux, install the
|
The procedure covers Windows through Ubuntu WSL2, macOS, and Linux including an Omarchy/Arch-like
|
||||||
host command from the repository with `./scripts/install-tht.sh`; Windows uses
|
host. It uses the application clone, one installation secret bundle, protected repository
|
||||||
`./scripts/install-tht.ps1`. The installer builds or verifies the native command and checks that
|
credentials when needed, and a terminal command. No host Node.js, Python or Pi installation is
|
||||||
`tht` is resolvable on `PATH`.
|
required.
|
||||||
|
|
||||||
The stack contains `frontend`, `core`, `catalog-db`, `qdrant`, `embedding`, and the one-shot
|
## What must be ready
|
||||||
`embedding-model-init` and `catalog-migrate` services. DWH and model-provider endpoints are
|
|
||||||
external installation settings. Pi runs inside `core`; do not install a host Pi executable for
|
|
||||||
the application runtime.
|
|
||||||
|
|
||||||
Secrets, certificates, Pi authentication, and workspace endpoint bindings are protected
|
You need Docker with Compose v2, Git, Bash, curl, OpenSSL and shasum. You also need access to the
|
||||||
installation-local files. Never put them in a workspace descriptor, an env file intended for
|
workspace repository and the values supplied by its owner: repository URL/branch, DWH endpoint,
|
||||||
version control, a URL, or a command line.
|
database/schema, transport, credentials or certificates, Evidence credentials when applicable,
|
||||||
|
and LLM provider/API-key information.
|
||||||
|
|
||||||
## Create the local installation
|
The workspace repository and the THothII application repository are different. A workspace
|
||||||
|
descriptor may declare Evidence, but database passwords and installation bindings are stored in
|
||||||
|
the installation Catalog, not in Git.
|
||||||
|
|
||||||
From the repository root, start the interactive setup and select the local profile:
|
## One guided command
|
||||||
|
|
||||||
```sh
|
After cloning THothII, checking prerequisites and installing tht, run:
|
||||||
tht setup --profile local --shell-mode full --shell-default-locale en
|
|
||||||
```
|
|
||||||
|
|
||||||
It writes the selected non-secret descriptor below `deploy/<installation-id>/`, the associated
|
~~~
|
||||||
operator env file, and can create protected secret templates. Keep the descriptor path: pass it
|
tht setup --complete --profile local --shell-mode full --shell-default-locale en
|
||||||
to commands as `--installation /absolute/path/thothii-installation.yaml` when more than one
|
~~~
|
||||||
installation can be discovered.
|
|
||||||
|
|
||||||
The explicit shell options are important: compatibility defaults without them
|
The first run creates protected placeholders under deploy/local/secrets/. Fill the required
|
||||||
are embedded/en/omics-portal, which expects an Omics document. The Mac's standalone
|
credential files and rerun the same command. The command validates the local files and paths,
|
||||||
installation must use full, with English as its initial locale. Existing browser
|
renders Compose, builds the images, starts catalog-db, runs catalog-migrate, starts the full
|
||||||
language preferences take precedence over that initial value. Full does not
|
stack, and pulls/activates the workspace repository. Evidence source files declared by the
|
||||||
configure authentication; setup separately bootstraps local login.
|
workspace are imported during activation.
|
||||||
|
|
||||||
For a server portal, use the [embedded/upstream procedure](authentication-upstream.md)
|
For an already configured installation:
|
||||||
instead of creating a second ThothII login. For a standalone server, use full
|
|
||||||
with [direct OIDC](authentication-oidc.md). Shell mode does not follow `profile`
|
|
||||||
automatically. See [configuration and regeneration](../operations/shell-and-localization.md)
|
|
||||||
before modifying an existing installation.
|
|
||||||
|
|
||||||
If the descriptor is prepared manually instead, begin with
|
~~~
|
||||||
[`thothii-installation.local.yaml`](examples/thothii-installation.local.yaml), set mode `0600` or
|
|
||||||
`0400`, and ensure `THT_INSTALLATION_CONFIG_SOURCE` in the selected env file points to that exact
|
|
||||||
file. Create the secret bundle from `deploy/secrets/thothii.secrets.example`, protect it, and set
|
|
||||||
the file locations and external endpoints in the env file. The required settings include:
|
|
||||||
|
|
||||||
- `PI_AUTH_FILE`, `THT_SECRETS_FILE`, and the catalog password source files;
|
|
||||||
- `THT_INSTALLATION_CONFIG_SOURCE` and the workspace Git remote/branch;
|
|
||||||
- the DWH and model-provider endpoints; and
|
|
||||||
- `THT_AUTH_CONFIG_ROOT` for local authentication or the OIDC configuration selected during setup.
|
|
||||||
|
|
||||||
For the supported secret names and the metadata-generation model credential boundary, see the
|
|
||||||
`deploy/secrets/README.md` file in the installation checkout. It is intentionally not published
|
|
||||||
as a documentation page because it describes a protected local-file contract.
|
|
||||||
|
|
||||||
## Start and verify
|
|
||||||
|
|
||||||
For the normal local path, use the launcher:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
./scripts/run-stack.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
It builds `core`, starts `catalog-db`, runs `catalog-migrate`, then keeps the base plus local
|
|
||||||
Compose profile in the foreground. Database migrations are deliberately not a hidden backend
|
|
||||||
startup action. Open `http://127.0.0.1:8080` unless `THOTH_HTTP_PORT` was changed.
|
|
||||||
|
|
||||||
In another terminal, verify the installation without changing it:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
tht --installation /absolute/path/thothii-installation.yaml doctor --json
|
|
||||||
tht --installation /absolute/path/thothii-installation.yaml status
|
tht --installation /absolute/path/thothii-installation.yaml status
|
||||||
```
|
tht --installation /absolute/path/thothii-installation.yaml doctor --json
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml workspace test --json
|
||||||
|
~~~
|
||||||
|
|
||||||
`/health` verifies application-process readiness; `tht doctor` is the diagnostic surface for
|
doctor --json is the non-destructive general core test. workspace test also probes the configured
|
||||||
Compose, configuration, workspace, workflow, and Pi prerequisites.
|
database, Evidence, Qdrant and embedding service for every active workspace. It requires the
|
||||||
|
workspace database to have been configured in Database Management first.
|
||||||
|
|
||||||
## Routine lifecycle and next steps
|
## Installer-only completion
|
||||||
|
|
||||||
Use `tht start [--build]`, `tht stop`, `tht logs`, and `tht doctor` rather than composing ad-hoc
|
The installer must still decide which LLMs and API keys are approved, configure and test each
|
||||||
container commands. Named volumes retain settings, Pi state, workspace registry, sessions,
|
workspace database, synchronize its schema, generate and consolidate descriptions, create Qdrant
|
||||||
Qdrant data, and embedding models across `docker compose down`; removing them requires the
|
entries, review naming-based FK suggestions alongside schema FKs, and load the approved
|
||||||
explicit destructive `--volumes` form.
|
relationships. The final declaration of completeness requires green doctor and workspace test
|
||||||
|
results plus one real natural-language question completed through final SQL.
|
||||||
|
|
||||||
After the stack is healthy, configure authentication if setup did not do so, then continue with
|
Migrations are part of setup --complete. Do not mix this installation’s descriptor or volumes with
|
||||||
[Workspace operations](../operations/workspaces.md). For server profile, reverse proxy, backups,
|
a different Compose environment. Preserve the descriptor, credentials, Catalog and persistent
|
||||||
and recovery, use the deployment program and its manual gates; the server profile is not a
|
volumes; do not use docker compose down --volumes as a routine stop.
|
||||||
drop-in replacement for the local command above.
|
|
||||||
|
See the guides for the Windows/macOS/Linux prerequisite matrix, workspace repository explanation,
|
||||||
|
secret layout and Gate A/Gate B acceptance checks.
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
# Installation preflight and release manifest
|
||||||
|
|
||||||
|
The native operator protocol is version 1. `installation preflight` is the independent
|
||||||
|
step-3 host check. `installation plan` repeats document validation, performs step-5
|
||||||
|
live checks and writes an owner-only JSON plan plus a separate owner-only `.key` file.
|
||||||
|
Neither command creates containers, imports bindings, modifies a database or invokes
|
||||||
|
model generation. Exit codes are 0 (checks passed), 1 (blocking error), and 2 (usage).
|
||||||
|
JSON stdout contains only the report. Checks carry stable `id`, `outcome`, `field`
|
||||||
|
and `action`; outcomes are `passed`, `error`, `warning`, `deferred-to-runtime`.
|
||||||
|
|
||||||
|
## Release manifest schema 1
|
||||||
|
|
||||||
|
The manifest is a local JSON file shipped with the verified operator/release bundle.
|
||||||
|
Required keys:
|
||||||
|
|
||||||
|
| Key | Contract |
|
||||||
|
| --- | --- |
|
||||||
|
| `schema_version` | `1` |
|
||||||
|
| `version` | Semantic release version, optionally prerelease |
|
||||||
|
| `revision` | 40 lowercase hexadecimal Git commit characters |
|
||||||
|
| `validator_protocol` | `1`; incompatible consumers refuse the manifest |
|
||||||
|
| `requirements` | `cpus`, `memory_bytes`, `disk_bytes`; at least 2 CPUs, 4 GiB Docker memory and 10 GiB installation filesystem space |
|
||||||
|
| `components` | Includes `pi`, `catalog-migrations`, `workspace-maintenance` |
|
||||||
|
| `images` | Exactly `core`, `frontend`, `catalog`, `qdrant`, `embedding`; each maps `linux/amd64` and/or `linux/arm64` to a `docker.io/...@sha256:...` **single-platform image digest** |
|
||||||
|
| `files` | Relative packaged resource paths to SHA-256; no traversal, links or absolute paths; maximum 256 files, 32 MiB per resource |
|
||||||
|
| `compose` | Ordered relative Compose file paths present in `files` for this release configuration |
|
||||||
|
|
||||||
|
Include the selected `deploy/compose.git-https.yaml` or `deploy/compose.git-ssh.yaml`
|
||||||
|
transport overlay in `files`. Standard transport overlays are resolved from the
|
||||||
|
release while absent in the installation directory; existing authored overrides
|
||||||
|
remain input files. Compose must resolve all eight services: core, frontend,
|
||||||
|
catalog-db, catalog-migrate, workspace-maintenance, qdrant, embedding and
|
||||||
|
embedding-model-init. The two maintenance services share the core digest; embedding
|
||||||
|
initialization shares the embedding digest. Source builds and undeclared services
|
||||||
|
are rejected in this prebuilt path. The explicit source path is a separate ticket.
|
||||||
|
|
||||||
|
`docker manifest inspect --verbose` checks each selected immutable image and its
|
||||||
|
platform without pulling layers. `docker compose config --format json` checks the
|
||||||
|
effective service configuration. Compose receives only Docker connection/trust,
|
||||||
|
proxy and executable-discovery host variables; application parameters come from
|
||||||
|
the prepared environment file. Raw Docker output is never copied into reports.
|
||||||
|
Each preflight Docker command has a 15-second bound. Public image publication is
|
||||||
|
verified separately; controlled manifest tests alone do not certify host acceptance.
|
||||||
|
|
||||||
|
## External checks and bounds
|
||||||
|
|
||||||
|
- Git HTTPS: authenticated `GET /info/refs?service=git-upload-pack`, configured CA,
|
||||||
|
no redirects, selected branch advertised, 1 MiB response and 5-second bound.
|
||||||
|
Git SSH uses its prepared key/known-hosts and `git-upload-pack --advertise-refs`
|
||||||
|
with the same response/time bounds; no checkout or push occurs.
|
||||||
|
- PostgreSQL: the existing Catalog diagnostic adapter authenticates and reads
|
||||||
|
`current_database()` plus schema `USAGE`; no user tables are modified.
|
||||||
|
- REST database transport: existing Catalog diagnostic `GET` with the configured
|
||||||
|
bearer/API-key header and status validation. SSH database bindings cannot pass
|
||||||
|
this NL-to-SQL installation plan because runtime sessions do not support them.
|
||||||
|
- Evidence: local paths were already validated. HTTP performs bounded GET requests
|
||||||
|
and cancels response bodies; signed URL identities must match authored provenance.
|
||||||
|
S3 performs one `ListObjectsV2` request with `MaxKeys: 1`, no retries, explicit
|
||||||
|
file credentials and the canonical Evidence egress policy. These metadata requests
|
||||||
|
can incur normal remote-service request charges; they do not run LLM generation.
|
||||||
|
Each external request has a 5-second bound; the native database/Evidence helper
|
||||||
|
has a 60-second aggregate bound. Correct unavailable services before repeating.
|
||||||
|
- Explicit model endpoints: DNS/TCP/TLS origin reachability, without generating
|
||||||
|
tokens. Built-in endpoint resolution, provider authentication and model smoke
|
||||||
|
operations use the bundled Pi SDK at runtime; the report never claims those
|
||||||
|
operations have already passed.
|
||||||
|
|
||||||
|
No unreachable configured external dependency is converted to a deferred success.
|
||||||
|
Runtime obligations have explicit identities: `container-network`,
|
||||||
|
`catalog-initialization`, `pi-operation`, `local-embedding`,
|
||||||
|
`workspace-preprocessing`, `workspace-readiness`. These must be discharged by the
|
||||||
|
execution/readiness tickets before final success. Host disk inspection cannot prove
|
||||||
|
Docker Desktop VM free storage; its separate storage warning remains explicit.
|
||||||
|
|
||||||
|
## Input identity and freshness
|
||||||
|
|
||||||
|
The plan records normalized installation configuration, release digests, validator
|
||||||
|
build identity, verified input paths, local workspace content and its Git HEAD when
|
||||||
|
available (otherwise a content snapshot). Files are bounded to 32 MiB each and
|
||||||
|
256 MiB total; workspace/auth trees to 10,000 entries, without links or special files.
|
||||||
|
Credential contents are never serialized. An HMAC covers the private inputs and
|
||||||
|
plan using a separate random 32-byte owner-only key; no public unkeyed secret hash
|
||||||
|
is generated. Credential rotation invalidates the plan. Added/deleted/changed
|
||||||
|
workspace files invalidate it as well. Changes during the checks abort publication.
|
||||||
|
Plan output never overwrites an existing plan or key.
|
||||||
|
|
||||||
|
Execution and resumption call `ReadExecutionPlan` **and repeat live checks and
|
||||||
|
credential reads before mutations**. A valid seal alone does not certify current
|
||||||
|
network availability, Docker state or runtime readiness. Keep both plan files
|
||||||
|
private and outside the workspace repository; they are installation-local artifacts.
|
||||||
|
|
||||||
|
## Non-interactive platform execution
|
||||||
|
|
||||||
|
`tht --installation ABS_DESCRIPTOR installation apply --plan ABS_PLAN [--json]`
|
||||||
|
requires an operator whose version and revision match the manifest. Plans must
|
||||||
|
include the manifest and bootstrap paths; regenerate older plans. The only permitted
|
||||||
|
absent-input transition is materialization of a standard release transport overlay
|
||||||
|
with exactly its packaged digest. All other input changes invalidate execution.
|
||||||
|
|
||||||
|
The local profile uses the preparing non-root Unix operator's UID/GID for core,
|
||||||
|
maintenance, migrations and PostgreSQL. Original private authentication directory
|
||||||
|
and credential mounts remain authoritative. A pinned, offline one-shot helper seeds
|
||||||
|
only installation-owned volumes, retaining a root-owned initialization marker for
|
||||||
|
interruption recovery. Existing ready volumes are never recursively chowned.
|
||||||
|
Account collisions and foreign volumes stop execution. This requires local Docker;
|
||||||
|
Windows runs inside WSL2 rather than the native Windows shell.
|
||||||
|
|
||||||
|
The lifecycle lock excludes concurrent operations. Asset publication and journal
|
||||||
|
updates are atomic. Every retry repeats reconciliation, even after a completed
|
||||||
|
journal stage. Pull and service startup have 30-minute bounds; Catalog startup and
|
||||||
|
migration have 5-minute bounds; final health inspection has a 1-minute bound.
|
||||||
|
Cancellation cleans up named one-shot containers and releases the lock. Hard-killed
|
||||||
|
processes require explicit stale-owner inspection; automatic destructive repair is
|
||||||
|
not performed. Errors contain a stage/action without raw Docker output or secrets.
|
||||||
|
|
||||||
|
Binding import uses a named, bounded one-shot client on the Compose network. Protected
|
||||||
|
bootstrap material travels through stdin, never arguments or journals. The client logs
|
||||||
|
in through local authentication, obtains CSRF protection, calls permission-checked
|
||||||
|
administration services, and logs out. Prepare `authentication.username` and
|
||||||
|
`authentication.passwordFile` in `database-bootstrap.yaml`; offline validation checks
|
||||||
|
the account/password against the private local registry and seals that file too.
|
||||||
|
|
||||||
|
The registry consumes the exact prepared Git file inventory and optional commit, without
|
||||||
|
retargeting or refreshing an existing checkout. Binding creation and its durable import
|
||||||
|
receipt commit together in the Catalog. The receipt survives administrative deletion.
|
||||||
|
Reruns compare live configuration and encrypted-store contents, retain equivalent values,
|
||||||
|
and stop on divergence. No bootstrap document becomes runtime authority. The application
|
||||||
|
tests the imported connection; a successful host probe alone is insufficient.
|
||||||
|
|
||||||
|
Success reports `platform_ready: true`, `bindings_ready: true`, `workspace_ready: true`.
|
||||||
|
The bounded `binding_import` report distinguishes authentication, workspace reconciliation,
|
||||||
|
binding reconciliation and container connectivity failures. `workspace_preparation`
|
||||||
|
reports existing Catalog synchronization and preprocessing outcomes. Pending destructive
|
||||||
|
review returns exit 3 with `schema_review_required`; resolve it in Administration and
|
||||||
|
repeat apply. Other failures return exit 1. No confirmation, curation overwrite, AI
|
||||||
|
description generation or Memory clearing is implicit. Current completed stages are reused.
|
||||||
|
|
||||||
|
`runtime_checks` retains workspace diagnostics (DWH, Evidence, Qdrant and embedding),
|
||||||
|
workflow diagnostics and Pi/default-provider smoke as pending/passed/failed. These
|
||||||
|
checks use bounded named one-shot containers, preserving cancellation cleanup. The
|
||||||
|
Pi smoke sends a short provider request with no DWH context and may incur usage.
|
||||||
|
Runtime failure preserves platform/binding success but leaves workspace readiness false.
|
||||||
|
`functional_acceptance` stays false: only a real human-reviewed question provides that
|
||||||
|
acceptance. Published preview.5 predates binding import and readiness; use a subsequent
|
||||||
|
matching image/operator release for this extension.
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
# Pubblicare immagini e pacchetto operatore / Publish images and operator bundle
|
||||||
|
|
||||||
|
## Italiano
|
||||||
|
|
||||||
|
Per l'avvio automatico usare la
|
||||||
|
[preview.5](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.5):
|
||||||
|
include `installation apply`, immagini e bundle Linux amd64/arm64. L'avvio della
|
||||||
|
piattaforma è stato verificato dal pacchetto pubblico; import dei binding, readiness
|
||||||
|
dei workspace e collaudi sui sistemi operativi restano passi successivi.
|
||||||
|
|
||||||
|
Questo comando è riservato al manutentore. L'utente finale scarica il pacchetto e
|
||||||
|
le immagini già compilati. La prima prerelease riguarda **Linux amd64**, utilizzato
|
||||||
|
da Ubuntu WSL2 su Windows e successivamente da Omarchy; non certifica ancora il
|
||||||
|
percorso completo di installazione o i collaudi manuali.
|
||||||
|
|
||||||
|
Prerequisiti del manutentore: Git, Node 24/npm, Go indicato in `tools/tht/go.mod`,
|
||||||
|
Docker con Buildx e capacità di eseguire Linux amd64, `tar`. Bun viene installato
|
||||||
|
dal lock npm e serve soltanto per compilare il pacchetto. Il commit da pubblicare
|
||||||
|
deve essere già disponibile sul repository Gitea pubblico.
|
||||||
|
Eseguire il produttore su Linux, WSL2 o macOS; la shell Windows nativa non è supportata.
|
||||||
|
|
||||||
|
La prima [prerelease Linux amd64](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.1)
|
||||||
|
è disponibile: `0.1.0-install-preview.1`, con immagini pubbliche
|
||||||
|
[core](https://hub.docker.com/r/tylconsulting/thothii-core) e
|
||||||
|
[frontend](https://hub.docker.com/r/tylconsulting/thothii-frontend).
|
||||||
|
|
||||||
|
1. Eseguire `docker login` sul computer di pubblicazione con un account autorizzato
|
||||||
|
a creare repository pubblici e pubblicare immagini nel namespace scelto.
|
||||||
|
Usare un credential store Docker: il token non va passato sulla riga di comando,
|
||||||
|
scritto nel repository o copiato nel pacchetto.
|
||||||
|
2. Predisporre nel credential helper Git l'accesso al repository Gitea con diritto
|
||||||
|
di creare rilasci e allegati. Il comando riusa quelle credenziali senza stamparle.
|
||||||
|
3. Installare le dipendenze del produttore con `cd backend && npm ci`, poi eseguire:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node scripts/publish-installation.mjs \
|
||||||
|
--revision COMMIT_GIA_PUBBLICATO \
|
||||||
|
--version 0.1.0-install-preview.1 \
|
||||||
|
--namespace tylconsulting \
|
||||||
|
--platforms linux/amd64 \
|
||||||
|
--output /percorso/privato/rilascio-0.1.0-install-preview.1
|
||||||
|
```
|
||||||
|
|
||||||
|
La directory di output deve essere nuova o vuota e avere un genitore esistente.
|
||||||
|
Diventa privata e contiene stato di ripresa, log del produttore, archivi e checksum.
|
||||||
|
Non è una directory di installazione. Il produttore usa un worktree temporaneo al
|
||||||
|
commit richiesto, così modifiche locali, segreti e workspace non entrano nelle build.
|
||||||
|
|
||||||
|
Il comando prepara `tylconsulting/thothii-core` e `tylconsulting/thothii-frontend`
|
||||||
|
come repository pubblici, costruisce e pubblica le immagini versionate, risolve i
|
||||||
|
digest di tutte le immagini e crea gli archivi del comando nativo con Compose e
|
||||||
|
risorse di inizializzazione. Catalog migration e workspace maintenance usano lo
|
||||||
|
stesso digest core. PostgreSQL, Qdrant e Ollama restano immagini upstream.
|
||||||
|
|
||||||
|
Prima di rendere pubblico il rilascio Gitea, vengono verificati pull anonimi delle
|
||||||
|
immagini, smoke test senza rete di core/frontend, checksum e download degli allegati.
|
||||||
|
Una build o un upload incompleto lascia il rilascio **in bozza**. Per riprovare,
|
||||||
|
rieseguire lo stesso comando con gli stessi parametri e la stessa directory.
|
||||||
|
Immagini già presenti devono appartenere allo stesso commit/versione; allegati
|
||||||
|
esistenti devono avere lo stesso checksum. Il produttore non sostituisce versioni
|
||||||
|
pubblicate con contenuti diversi. Conservare la directory fino al completamento.
|
||||||
|
|
||||||
|
Il risultato pubblico comprende `thothii-VERSION-linux-amd64.tar.gz` e
|
||||||
|
`SHA256SUMS.txt`. L'archivio contiene `bin/tht`, il validatore affiancato,
|
||||||
|
`release-manifest.json`, Compose, SQL/script di inizializzazione e guide. Non
|
||||||
|
contiene credenziali, dati dei workspace o database di esempio. La verifica su
|
||||||
|
questa macchina di pubblicazione non sostituisce il successivo collaudo Windows.
|
||||||
|
|
||||||
|
## English
|
||||||
|
|
||||||
|
Use [preview.5](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.5)
|
||||||
|
for automatic platform startup: it includes `installation apply`, Linux amd64/arm64
|
||||||
|
images and native bundles. Platform startup was verified from the public archive;
|
||||||
|
binding import, workspace readiness and operating-system acceptance remain later steps.
|
||||||
|
|
||||||
|
This is a maintainer command. Consumers download precompiled images and the native
|
||||||
|
operator bundle. The first prerelease targets **Linux amd64** for Ubuntu WSL2 and
|
||||||
|
later Omarchy; full installation and real-host acceptance remain separate work.
|
||||||
|
|
||||||
|
The maintainer needs Git, Node 24/npm, the Go toolchain from `tools/tht/go.mod`,
|
||||||
|
Docker Buildx with Linux amd64 execution support, and `tar`. The npm lock supplies
|
||||||
|
Bun for producer builds only. Push the selected source commit to the public Gitea
|
||||||
|
repository before publication. Use Docker's credential store for `docker login`
|
||||||
|
and Git's credential helper for Gitea release/attachment permissions. Never pass
|
||||||
|
tokens as command arguments or include them in a checkout or archive.
|
||||||
|
Run the producer on Linux, WSL2 or macOS, not a native Windows shell.
|
||||||
|
|
||||||
|
The first [Linux amd64 prerelease](https://git.tylconsulting.it/mptyl/ThothII/releases/tag/installation-v0.1.0-install-preview.1)
|
||||||
|
is available as `0.1.0-install-preview.1`, with public Docker Hub core/frontend images.
|
||||||
|
|
||||||
|
From `backend`, run `npm ci`, then the command above with an explicit revision,
|
||||||
|
version, namespace, platforms and a new private output directory. A temporary Git
|
||||||
|
worktree isolates the selected commit. The producer publishes core/frontend to
|
||||||
|
Docker Hub and retains PostgreSQL, Qdrant and Ollama upstream. All runtime and
|
||||||
|
maintenance services use resolved immutable platform digests.
|
||||||
|
|
||||||
|
The Gitea release stays a draft until images, anonymous pulls, network-isolated
|
||||||
|
smoke checks and uploaded bundle checksums pass. An interrupted run can be retried
|
||||||
|
with the same arguments and output directory. Existing images must match the
|
||||||
|
source/version, and existing attachments must match their checksum; published
|
||||||
|
versions are not overwritten. Producer logs and retry state stay local.
|
||||||
|
|
||||||
|
Download the matching `.tar.gz` and `SHA256SUMS.txt` from the public Gitea prerelease,
|
||||||
|
verify the archive checksum, then extract it. Keep the two executables together.
|
||||||
|
The bundle needs no application checkout, Node, Bun, Python or compiler on the
|
||||||
|
consumer host. It carries the manifest, Compose and initialization assets, but no
|
||||||
|
installation credentials, workspace data or example databases. Linux arm64 can be
|
||||||
|
selected explicitly for later release work; it does not imply macOS acceptance.
|
||||||
|
|
||||||
|
Developer regression checks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd backend
|
||||||
|
node --test scripts/release-*.test.mjs
|
||||||
|
```
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# Display mode and language
|
||||||
|
|
||||||
|
ThothII can run with its own application header (**full**) or inside an integrated
|
||||||
|
portal (**embedded**). Display mode and authentication are separate choices.
|
||||||
|
|
||||||
|
| Installation | Display | Authentication |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Standalone local instance | `full` | Local ThothII account |
|
||||||
|
| Standalone server | `full` | Local accounts or configured OIDC provider |
|
||||||
|
| Integrated portal | `embedded` | Identity verified by the portal's trusted server proxy |
|
||||||
|
|
||||||
|
## Standalone setup
|
||||||
|
|
||||||
|
Follow the complete [Italian](standalone-manual-it.md) or
|
||||||
|
[English](standalone-manual-en.md) installation procedure. It explicitly selects
|
||||||
|
`--shell-mode full --shell-default-locale en` and separates configuration, credentials,
|
||||||
|
initial migrations and startup. Do not skip those steps by running setup alone.
|
||||||
|
|
||||||
|
The authored installation descriptor contains:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
shell:
|
||||||
|
mode: full
|
||||||
|
defaultLocale: en
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `it` for an Italian initial interface. Existing browser language preferences can
|
||||||
|
override that initial value. Full mode remembers language and theme in the browser.
|
||||||
|
|
||||||
|
For an existing installation, preserve the current descriptor and edit only the intended
|
||||||
|
settings; do not rerun setup to overwrite it. With a current host `tht` binary:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml installation generate
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml start
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml status
|
||||||
|
tht --installation /absolute/path/thothii-installation.yaml doctor --json
|
||||||
|
```
|
||||||
|
|
||||||
|
Generation updates derived configuration; it does not start services. `start` applies
|
||||||
|
the installation's normal lifecycle and is not guaranteed to touch only the frontend.
|
||||||
|
Follow the deployment's maintenance procedure and retain its network, authentication and
|
||||||
|
model settings. Do not edit generated files or remove persistent volumes.
|
||||||
|
|
||||||
|
## Authentication and embedded deployments
|
||||||
|
|
||||||
|
Full mode does not configure login by itself. See [local authentication](authentication-local.md)
|
||||||
|
or [OIDC](authentication-oidc.md), with [Authentik](authentik.md) as a provider option.
|
||||||
|
|
||||||
|
Embedded mode requires a compatible portal integration, not just a descriptor toggle.
|
||||||
|
The portal owns login/logout and supplies a server-verified identity. A presentation
|
||||||
|
adapter does not authenticate users. The core must not be reachable by a route that
|
||||||
|
bypasses the trusted proxy. Do not add a second OIDC login to an already authenticated
|
||||||
|
upstream deployment.
|
||||||
|
|
||||||
|
Portal implementation details belong to the
|
||||||
|
[developer integration reference in the repository](https://git.tylconsulting.it/mptyl/ThothII/src/branch/main/docs/install/authentication-upstream.md),
|
||||||
|
not to the standalone installation procedure.
|
||||||
|
|
||||||
|
## Three different languages
|
||||||
|
|
||||||
|
- **Interface language** controls labels, forms and application messages.
|
||||||
|
- **Session interaction language** is captured when a session is created. Resuming it
|
||||||
|
retains that language even if the interface language changes later.
|
||||||
|
- **Workspace language** concerns domain content and retrieval; switching the interface
|
||||||
|
does not translate Evidence, SQL, identifiers or database values.
|
||||||
|
|
||||||
|
In embedded mode the interface follows the portal's language and theme. A portal language
|
||||||
|
change may reload the page. Saved session artifacts remain available, but resuming work
|
||||||
|
is explicit; a reload does not by itself request a new model generation.
|
||||||