docs: converge operator guidance on tht

This commit is contained in:
2026-08-19 16:12:11 +02:00
parent 32a17d83a9
commit 1184b6db16
29 changed files with 544 additions and 380 deletions
@@ -1,5 +1,9 @@
# Internal Qdrant and Ollama Implementation Plan
> **Historical nomenclature:** this plan predates the native host CLI convergence. The current
> operator command is `tht`; any older `thothctl` smoke-script or rollback wording below is retained
> only as historical evidence.
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Make Qdrant and Ollama mandatory internal ThothII services while keeping the analytical
@@ -1,5 +1,9 @@
# Read-only Workspace Runtime Secrets Implementation Plan
> **Historical nomenclature:** this plan predates the native host CLI convergence. References to
> `thothctl` and `tools/thothctl` describe the implementation snapshot from which this plan was
> written; current operator commands and paths use native `tht` and `tools/tht`.
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Make workspace consumption strictly read-only while adding installation-scoped Git identity and persistent GUI-managed runtime secrets.
@@ -4,9 +4,9 @@
**Goal:** Validate local and OIDC authentication on macOS, deploy the exact feat/thoth-auth candidate to the Aritmolab/PSD server before merging it into main, and complete end-to-end acceptance with remote Authentik.
**Architecture:** Test the candidate first as a standalone local installation. Then install the same immutable Git revision on the existing PSD installation with the installation-aware thothctl lifecycle, leaving main untouched. Authentik provides OIDC login and a mandatory direct groups claim; ThothII maps exact external groups to roles and validates mapped groups through the Authentik catalog API.
**Architecture:** Test the candidate first as a standalone local installation. Then install the same immutable Git revision on the existing PSD installation with the installation-aware tht lifecycle, leaving main untouched. Authentik provides OIDC login and a mandatory direct groups claim; ThothII maps exact external groups to roles and validates mapped groups through the Authentik catalog API.
**Tech Stack:** macOS, Docker Desktop, Docker Compose, tht/thothctl, local Argon2id authentication, generic OIDC Authorization Code + PKCE, Authentik, PSD workspace registry, reverse proxy/TLS.
**Tech Stack:** macOS, Docker Desktop, Docker Compose, native host `tht` plus Python workflow `tht`, local Argon2id authentication, generic OIDC Authorization Code + PKCE, Authentik, PSD workspace registry, reverse proxy/TLS.
---
@@ -26,7 +26,7 @@ git status --short --untracked-files=all
Never deploy a moving branch name without checking its resolved SHA. Never put passwords, OIDC client secrets, Authentik API tokens, cookies, authorization headers, raw ID tokens, or password hashes in Git, shell history, screenshots, logs, or evidence.
Use protected operator values for <PUBLIC_URL>, <OIDC_ISSUER>, <AUTHENTIK_BASE_URL>, <OIDC_CLIENT_ID>, <THTCTL>, <INSTALLATION>, <WORKSPACE_ID>, and <OLD_SHA>.
Use protected operator values for <PUBLIC_URL>, <OIDC_ISSUER>, <AUTHENTIK_BASE_URL>, <OIDC_CLIENT_ID>, <THT_BIN>, <INSTALLATION>, <WORKSPACE_ID>, and <OLD_SHA>.
The Authentik contract is mandatory: a direct non-empty JSON array claim named groups; exact groups TOT Users and TOT Admin; mappings TOT Users -> user and TOT Admin -> admin; and a separate group-view-only API service account exposed only as THT_AUTHENTIK_API_TOKEN. Extra upstream groups are valid and silently ignored.
@@ -71,7 +71,7 @@ Expected: Docker Desktop and Compose are available and line-ending validation pa
```bash
bash scripts/build-local.sh
bash scripts/build-thothctl.sh
bash scripts/build-tht.sh
tht setup --profile local
```
@@ -176,12 +176,12 @@ Go/no-go: do not proceed to PSD if local login, role separation, logout, or reme
**Step 1: Capture live state**
```bash
THTCTL=<THTCTL>
THT_BIN=<THT_BIN>
INSTALLATION=<INSTALLATION>
"$THTCTL" --installation "$INSTALLATION" status
"$THTCTL" --installation "$INSTALLATION" doctor
"$THTCTL" --installation "$INSTALLATION" pi status
"$THTCTL" --installation "$INSTALLATION" pi doctor
"$THT_BIN" --installation "$INSTALLATION" status
"$THT_BIN" --installation "$INSTALLATION" doctor
"$THT_BIN" --installation "$INSTALLATION" pi status
"$THT_BIN" --installation "$INSTALLATION" pi doctor
git -C /srv/thothii/source/ThothII status --short --untracked-files=all
git -C /srv/thothii/source/ThothII rev-parse HEAD
```
@@ -190,14 +190,14 @@ Save the live SHA as <OLD_SHA> and capture image identities, workspace registry
**Step 2: Drain and back up**
Announce maintenance, close the reverse proxy or show its maintenance page, drain active work, and stop through thothctl. Create the protected, checksummed backup specified in docs/install/server.md, including runtime trees and PSD PostgreSQL/session data where applicable. Back up credentials separately. Never run docker compose down --volumes.
Announce maintenance, close the reverse proxy or show its maintenance page, drain active work, and stop through tht. Create the protected, checksummed backup specified in docs/install/server.md, including runtime trees and PSD PostgreSQL/session data where applicable. Back up credentials separately. Never run docker compose down --volumes.
**Step 3: Check preconditions**
```bash
git -C /srv/thothii/source/ThothII config --local core.autocrlf false
bash /srv/thothii/source/ThothII/scripts/verify-line-endings.sh
"$THTCTL" --installation "$INSTALLATION" update --check-only
"$THT_BIN" --installation "$INSTALLATION" update --check-only
```
Expected: descriptor, protected secrets, Pi-state mount, workspace repository binding, and Compose render remain valid before source changes.
@@ -207,7 +207,7 @@ Expected: descriptor, protected secrets, Pi-state mount, workspace repository bi
**Files:**
- Server source checkout: /srv/thothii/source/ThothII
- Server operator binary: protected THTCTL path
- Server operator binary: protected THT_BIN path
- Server installation descriptor and secret files: unchanged paths unless a reviewed auth update is required
**Step 1: Select the exact candidate**
@@ -226,21 +226,21 @@ Do not merge or rebase main. The running installation is intentionally based on
```bash
cd /srv/thothii/source/ThothII
bash scripts/build-local.sh
THT_THOTHCTL_OUTPUT_DIRECTORY=/srv/thothii/operator/build-output bash scripts/build-thothctl.sh
THT_THT_OUTPUT_DIRECTORY=/srv/thothii/operator/build-output bash scripts/build-tht.sh
```
Install the architecture-appropriate candidate thothctl only after its build succeeds. Keep the old operator binary recoverable.
Install the architecture-appropriate candidate tht only after its build succeeds. Keep the old operator binary recoverable.
**Step 3: Start and verify the candidate**
```bash
"$THTCTL" --installation "$INSTALLATION" update --check-only
"$THTCTL" --installation "$INSTALLATION" start --build
"$THTCTL" --installation "$INSTALLATION" status
"$THTCTL" --installation "$INSTALLATION" doctor --json
"$THT_BIN" --installation "$INSTALLATION" update --check-only
"$THT_BIN" --installation "$INSTALLATION" start --build
"$THT_BIN" --installation "$INSTALLATION" status
"$THT_BIN" --installation "$INSTALLATION" doctor --json
curl --fail http://127.0.0.1:8080/health
"$THTCTL" --installation "$INSTALLATION" pi doctor
"$THTCTL" --installation "$INSTALLATION" pi test
"$THT_BIN" --installation "$INSTALLATION" pi doctor
"$THT_BIN" --installation "$INSTALLATION" pi test
```
Expected: candidate frontend/core and internal services are healthy, no data volume was replaced, and the candidate SHA is recorded. Liveness alone is not release approval.
@@ -294,7 +294,7 @@ A missing mapped group must fail with redacted oidc_mapped_group_missing. Unmapp
If configuration requires process reload:
```bash
"$THTCTL" --installation "$INSTALLATION" pi restart --yes --drain
"$THT_BIN" --installation "$INSTALLATION" pi restart --yes --drain
```
Repeat authentication, doctor, and health checks. Do not substitute raw Compose commands.
@@ -329,13 +329,19 @@ During a controlled window, make discovery/JWKS unavailable or rename a mapped g
- Read: docs/install/server-workspace-registry.md
- Use: authenticated PSD browser sessions
**Step 1: Validate as administrator**
**Step 1: Validate the workspace and authentication from the host CLI**
In Workspace Management, select <WORKSPACE_ID> and run Validate workspace source. Expected: Git descriptor, Evidence/catalog invariants, and complete authentication readiness pass; result is redacted and identifies the workspace revision.
```bash
"$THT_BIN" --installation "$INSTALLATION" \
workspace inspect --workspace "$WORKSPACE_ID" --json
"$THT_BIN" --installation "$INSTALLATION" auth check --json
```
**Step 2: Test connections**
Expected: the workspace registry is ready, authentication readiness passes, and output is redacted while identifying the active workspace revision.
Run Test workspace connections for the selected workspace. Expected: protected DWH/Evidence secrets are used, status is redacted, and workspace source is unchanged.
**Step 2: Verify the application boundary**
Open the configured public URL, authenticate with the approved identity, and verify that the application reaches the selected workspace without unexpected `401`/`403` responses. Keep DWH/Evidence connection tests read-only and use only the existing approved smoke question.
**Step 3: Test ordinary-user authorization**
@@ -356,7 +362,7 @@ Do not run mutating production queries. Preserve only a session ID and redacted
**Files:**
- Create: docs/testing/evidence/2026-08-18-thothii-authentication-psd-acceptance.md or the approved external evidence location
- Read: docs/install/server.md and docs/contracts/thothctl-pi.md
- Read: docs/install/server.md and docs/contracts/tht-pi.md
**Step 1: Mandatory gates**
@@ -370,7 +376,7 @@ Do not run mutating production queries. Preserve only a session ID and redacted
| Candidate deploy | Server candidate status/doctor/health pass |
| Authentik | Direct groups claim, issuer/JWKS, secrets, catalog, and mapped groups pass |
| OIDC authorization | ordinary, admin, unmapped, malformed, logout, and outage cases pass |
| Workspace integration | Validate workspace source and test connections pass |
| Workspace integration | `tht workspace inspect` and `tht auth check` pass; the authenticated application reaches the selected workspace |
| PSD smoke | One harmless known-good session completes |
| Hygiene | No secrets, tokens, cookies, hashes, or raw claims in evidence |
@@ -380,9 +386,9 @@ Include candidate SHA, old SHA, timestamps, commands, browser cases, redacted di
**Step 3: Roll back a failed candidate**
1. Keep the proxy closed and preserve .thothctl/<installation-id>/ recovery state.
2. Do not use thothctl pi rollback as the whole-application rollback; it addresses only Pi lifecycle images.
3. Stop with thothctl.
1. Keep the proxy closed and preserve .tht/<installation-id>/ recovery state.
2. Do not use tht pi rollback as the whole-application rollback; it addresses only Pi lifecycle images.
3. Stop with tht.
4. Return the source checkout to <OLD_SHA>, rebuild old application/operator artifacts, and start through the same descriptor.
5. Run update --check-only, status, doctor, health, Pi smoke, workspace diagnostics, and one harmless session.
6. For ambiguous recovery, leave maintenance active and follow pi maintenance status / pi maintenance recover --yes. Never delete volumes, selectors, or recovery files to force progress.
@@ -400,4 +406,3 @@ Merge only after PSD owner acceptance, exact-SHA evidence, no unresolved auth/wo
## Handoff checklist
Deliver the redacted report, local result/SHA, PSD candidate SHA/images, Authentik provider and group mapping confirmation, workspace validation/connection results, backup/rollback status, and an explicit READY TO MERGE or NOT READY TO MERGE decision.
@@ -0,0 +1,92 @@
# Tht Documentation Convergence Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Align current documentation and documentation smoke checks with the converged native host CLI `tht`, while preserving historical references only where they describe past decisions or evidence.
**Architecture:** Treat `tools/tht/cmd/tht/main.go` as the canonical host CLI surface for installation, authentication, diagnostics, lifecycle, and workspace operations. Keep the Python `harness/.venv/bin/tht` distinction explicit for the workflow runtime, and update current operator/test instructions to invoke the native `tht` with `--installation`.
**Tech Stack:** Markdown documentation, shell smoke tests, Go CLI command surface, repository search-based verification.
---
### Task 1: Classify current and historical legacy CLI references
**Files:**
- Inspect: `README.md`, `PROJECT_STATE.md`, `AGENTS.md`, `docs/**`, `scripts/**`
- Reference: `tools/tht/cmd/tht/main.go`
**Step 1:** Build a complete occurrence inventory with a case-insensitive search for the former host CLI name and classify every match.
**Step 2:** Classify each occurrence as current operator documentation, documentation smoke expectation, executable/script contract, or historical design/evidence.
**Step 3:** Record the classification in the implementation notes before editing.
### Task 2: Update canonical operator and installation documentation
**Files:**
- Modify: `README.md`
- Modify: `AGENTS.md`
- Modify: `PROJECT_STATE.md`
- Modify: `docs/guida-utente.md`
- Modify: `docs/contracts/workspace-preprocessing-cli.md`
- Rename/update: `docs/contracts/tht-pi.md` as the current `tht` Pi contract
- Modify: relevant installation and architecture pages that expose operator commands
**Step 1:** Replace current host/operator invocations with `tht --installation ...`.
**Step 2:** Document the distinction between the native host CLI `tht` and the Python harness CLI invoked by the backend/runtime.
**Step 3:** Update command examples for `start`, `status`, `doctor`, `auth`, `workspace`, and `pi`.
**Step 4:** Add a short historical note only where a document must explain the former name.
### Task 3: Rewrite authentication acceptance and manual test instructions
**Files:**
- Modify: `docs/testing/authentication-manual-acceptance.md`
- Modify: `docs/plans/2026-08-18-thothii-authentication-acceptance-and-psd-deployment.md`
- Modify: `docs/install/authentication-local.md`
- Modify: `docs/install/authentication-oidc.md`
- Modify: `docs/install/authentik.md`
**Step 1:** Make `tht auth status`, `tht auth check`, `tht auth check --interactive`, and `tht doctor --json` the canonical terminal preflight.
**Step 2:** Use `tht status`, `tht start`, and `tht workspace inspect --workspace psd-clinical --json` for PSD deployment checks.
**Step 3:** Clarify that the P8 L2 gate is authentication-to-application integration through the first reviewer gate.
**Step 4:** Retain the prior functional test suite as a baseline and add only the authentication boundary smoke required for this acceptance.
### Task 4: Align documentation smoke tests
**Files:**
- Modify: `scripts/auth-docs-smoke.sh`
- Modify: `scripts/test-auth-docs-smoke.sh`
- Inspect/update: any current smoke script whose user-facing command examples still require the legacy CLI name
**Step 1:** Replace forbidden/current command assertions with `tht` equivalents.
**Step 2:** Preserve negative checks for obsolete authentication CLI wording.
**Step 3:** Run the positive and negative documentation fixtures.
### Task 5: Preserve or annotate historical material
**Files:**
- Inspect the historical discovery specification for context, without treating it as current operator documentation.
- Inspect: dated reports and archived acceptance scripts
**Step 1:** Do not rewrite historical titles, commit evidence, or old implementation names solely to erase history.
**Step 2:** Add a concise “historical nomenclature” note where an archived document could otherwise be mistaken for current instructions.
### Task 6: Verify the convergence
**Step 1:** Run `scripts/auth-docs-smoke.sh` and `scripts/test-auth-docs-smoke.sh`.
**Step 2:** Search active documentation for remaining legacy CLI references.
**Step 3:** Confirm every remaining match is either an explicit historical note, an ignored runtime directory name, or a non-document executable compatibility artifact.
**Step 4:** Run `git diff --check` and report the exact files changed plus any intentionally retained historical references.