# AGENT-PROMPT-v6-S0 — run one document through the stack · **COMPLETED EXECUTION RECORD**

> # 🛑 STOP — DO NOT RUN THIS AS A CURRENT TASK
>
> **This task is done. S0 closed 8/8 on 2026-08-18.** The run it describes was carried out and its
> result is recorded in `docs/STATE.md` (the nine steps) and `docs/project-todo-v6.md` (S0-4 and
> S0-5, both `[x]`). This file is kept as the **historical execution record** of how that run was
> shaped — it is **not an instruction and not an open task**.
>
> **Do not re-run it, re-stand the environment, re-submit GD-1, or re-fill the nine-step table.**
> Everything below the banner is preserved in its original imperative voice **as history**; read it
> that way. If a later phase needs another one-document run, it gets its own prompt with its own
> scope — this one is not reopened, and nothing here authorises a fresh submission, a fresh
> environment or any write.

**Date:** 2026-08-10 · rev. 9 (2026-08-18) — **closed; superseded by the recorded outcome below**
**Plan:** `docs/V6.md` · **Backlog:** `docs/project-todo-v6.md` · **State:** `docs/STATE.md`
**Authority:** Miguel

---

## What actually happened — the closing record

The final, successful run was **2026-08-18**. The **exact pinned GD-1 bytes** were submitted through
`/api/channel-intake/v1` using the **verified dedicated channel-intake client**, against a
**pre-existing enabled sender mapping**, an **isolated PostgreSQL** instance and an **isolated Local
scratch** storage root, on installed artifact **`a8d0a4bab7b2f93920ad29819d442e01c04dd374`**. That
artifact is **ancestral to `main`**, so the run is evidence about it and **not a demonstration of
the current `main` runtime**; `main`'s governed staged migrations were **not** bypassed. Outbound
**business** integrations were **deliberately disabled** — Cegid, Microsoft Graph and the financial
push paths — so **no external business-integration job, commit, operation or call was attempted**.
What did occur was **OIDC discovery and token acquisition against the configured Identity
authority**, as authentication to the Sibyla API for the intake submission: **no token, client id or
value is recorded here.**
**No live write occurred and no sender mapping was created, enabled or edited.**

The nine steps as recorded in `docs/STATE.md`: **1 works** (201 register · 200 same-idempotency-key
replay with `replayed=true` · 200 upload and status) · **2 broken** (Invoice recognised; internal
company, counterparty and direction unresolved) · **3 works** (Hermes job Succeeded on attempt 1,
response strictly validated and persisted as one revision with two lines; the deterministic gates
**executed and returned false**, raising warning `LINE_SIGN_AMBIGUOUS` and routing to review —
executed, never "passed") · **4 broken** (cataloging ran; direction and counterparty unresolved, and
the July `DocumentLine` has no account-mapping surface) · **5 missing** (no DOCLOG/FDCHDR/FDCDTL
writer; application persistence and audits did work) · **6 works** (`AwaitingReview`/`NeedsReview`
on the false gates, with the warning and a fingerprint-incomplete audit entry; **no human decision
was performed**) · **7 missing** (no correction-learning write-back) · **8 not reached** (outbound
**business** integrations deliberately disabled; the OIDC exchange that did happen was
authentication to the Sibyla API, not a business-integration call) · **9 works for fiscal GD-1** (exact original stored immutably
and rehashed to match; the non-fiscal archive branch was not applicable and was not invoked).

**Cleanup, verified after the run:** the disposable resources and the sensitive snapshots were
removed; the temporary listeners, the container and the temporary directory are **absent**; the live
Worker remains **Running** under `.\GottSibylaDocumental`; and the original GD-1 file in the
read-only prototype is **unchanged**. The **2026-08-10** run recorded earlier was **preliminary and
failed to admit a document**; it is superseded and is not the state of anything.

No sender identity, raw identifier, extracted field value, credential or connection string is
recorded here or anywhere in this file.

---

## Historical — the task as it was written

*Everything from here on is the original prompt text, retained for the record. It describes work
that has been completed. Read it as an account of what was asked for, not as something to do.*

---

## Read this first

`docs/archive/` holds 62 files and 1.7 MB of v5 governance record — go-aheads, amendments,
approvals, rejections, 20-item checklists, byte-identical neutralisation rituals. **It is history,
not instruction. Do not read it for guidance and do not imitate its shape.** If you find yourself
writing a document like those, stop.

`docs/AGENT-PROMPT-v5-P1-1b-scope1-goahead.md` in that folder is **revoked** — it authorises a bulk
import that V6-D3 cancels. It carries a banner saying so.

Read `AGENTS.md`, `docs/V6.md` §2–§3, and `docs/STATE.md`. That is the whole briefing.

**This prompt is one page because only one task is left.** Its first revision was four times longer;
everything else in it has since been done, and deleting those sections was the point.

---

## What is already done

*(As written on 2026-08-10. **Superseded:** all eight S0 items are closed as of 2026-08-18.)*

Seven of the eight S0 items are closed. P1-1b closed and Piece D merged; Scopes 1–8 revoked; the
nine P1-1a / Piece A-B-C migration files on `main` with a green pipeline; GitLab CI running restore,
Debug and Release builds and the test suite on merge requests and branch pushes; the process corpus
archived; `AGENTS.md` pointing at v6; **V6-O1 decided** (verification replaces ceremony — see Rules);
and the izibizi prerequisites defined and owned (Miguel for the host, Luís for the credentials, in
`docs/deployment/izibizi-activation.md`).

**None of it tells us whether the system works.** That is the whole of what is left, and it is
yours.

---

## Preflight — four things the environment needs

Check these before starting. Three are routine; the fourth decides how far you can get.

1. **PostgreSQL** and `ConnectionStrings:SibylaDb` — the default is empty. The API applies
   migrations at startup, so the account needs schema-change rights.
2. **`Sibyla:StorageRoot`** — the default is `C:\WIP\GOTT.Sibyla\devStorage`, a **stale path**
   from an older checkout. Point it at this repository's `devStorage`, or anywhere writable.
3. **Identity** — `Identity:Authority` is `https://login.gottsolutions.net`. It must be reachable.
   The **dedicated Apolo channel-intake client already exists and was verified live on 2026-08-18**:
   its configuration (authority, API base URL, client id, secret, scope) is present and non-empty in
   the effective Hermes runtime environment, OIDC discovery returned 200, `client_credentials`
   returned 200, and the token's sanitized claims hold — issuer = configured authority, subject =
   configured client, audience contains `sibyla-api`, scope set exactly
   `{sibyla.channel-intake.write}`, expiry current. **Confirm it still issues a token; do not create,
   provision, rotate or re-scope any client, secret or user, and never print or record the client id,
   secret or token.** Eligible interactive `FinancialOperations` users (Administrator, Finance,
   Accounting) also already exist, so none needs creating — but the dedicated client is the intended
   intake path for this task, not an interactive upload.
4. **Hermes**, and this is the one that matters. `HermesExtraction:ExecutablePath`, `AgentHome`,
   `WorkingRoot`, profile `documental-agent`, plus `PdfTextExtractorExecutablePath`.
   `HermesDocumentExtractionClient` is the **only** implementation of `IDocumentExtractionClient` —
   there is no dev stub — so without a working Hermes install, steps 3 and 4 cannot run at all.

Note that in `Development` the startup validator only *warns* about missing configuration; it fails
closed only in production. So the app will start with Hermes unconfigured and then fail at the
extraction job. That is a finding worth recording precisely, not a surprise to debug around.

**If Hermes is not available, run S0-4 anyway.** Steps 1, 2, 5 and 9 — arrival, registration,
persistence and storage — do not depend on it. Record 3 and 4 as `blocked — no Hermes runtime` with
what you observed, and carry on to the rest. A table with two blocked rows and seven answered ones
is a far better outcome than not running. Do **not** stub the extraction client to get past it: a
fake answer in step 3 makes steps 4 to 8 meaningless.

## Your task — S0-4

Stand up a dev environment: PostgreSQL, the API, the Web app, the Worker. The PostgreSQL instance
and the storage root must be **disposable and isolated** — a throwaway database and a scratch
storage root, never a shared or live one — and outbound integrations stay **disabled**
(`Cegid:Enabled=false`, Moloni off): nothing in this task may reach an ERP.

Submit the **exact pinned GD-1 bytes** — unmodified, byte-for-byte — through
`/api/channel-intake/v1` using the **existing dedicated Apolo channel-intake client**, with a
**stable idempotency key and correlation id** recorded before the call so the submission can be
identified and, if repeated, proven idempotent. Before the run, **verify that an enabled sender
mapping already exists** for the sender identifier you will submit — an enabled `UserChannels` row
bound to an active user profile. **Do not create, enable or edit a sender allowlist row to make the
test pass.** If no enabled mapping exists, that is the finding: record `broken` at step 1 with the
`channel_intake_sender_not_authorized` outcome you observed and carry on with everything it does
not block.

Then follow the document through `ExtractDocumentJobHandler`, `HermesProcessInvoker`,
`ExtractionResponseValidator` and `DocumentCatalogingService`.

For each of the nine steps in the table in `docs/STATE.md`, replace `unknown` with **works**,
**broken** (with the error), or **missing**. Fill that table in place — do not write a separate
report.

Three things to hold on to:

**Breakage is the finding, not a failure of the task.** The stack has not run since 24 July and the
schema changed underneath it. A table of honest failures is a complete deliverable.

**Do not fix what you find**, beyond the minimum needed to reach the next step. Fixing is S1 and S2
work, and a fix invented before the whole picture exists is usually the wrong fix. If you do have to
patch something to proceed, note it as a patch and keep going.

**If the stack is unrecoverable rather than merely broken, say so plainly.** That reverses V6-D1 —
the decision that the July stack is the spine — and it is exactly the fact this task exists to
surface. Do not soften it.

Then finish `docs/STATE.md`: the table, and one short paragraph on what S1 and S2 have to change
given what you found. **One page.** It is updated in place, never appended to.

---

## Rules

V6-O1, decided 2026-08-10: pipeline green → merge; **green pipeline, not a local run**. The
adversarial pass comments, it does not gate. Fix forward. Measured claims only — what you ran and
what it returned. Branch `s0/<slug>` off `main`.

The merge-request rules and the application's runtime gates are **different planes**. Nothing in
this task approves a document or writes to an ERP; if you find yourself needing either, you have
left the task.

**Stop-and-report when you find a real contradiction** — an observed fact that makes the instruction
impossible. Not as a way to ask permission. State the fact, the conflict, your proposed resolution,
and carry on with everything it does not block.

## Not authorised

Importing document data of any kind. Any new migration. Writing to a shared or live database. Any
prototype write. Any ERP call against a live tenant. Starting S1 or later work.

## Report

The nine-step table in `docs/STATE.md`, anything you patched to proceed, anything you stopped on,
and one paragraph on what S1 should change given what you found. Then stop — S1 gets its own prompt,
and it will be shorter than this one.

---

**End of the historical prompt. It was reported and closed on 2026-08-18** — the nine-step table is
in `docs/STATE.md`, S0-4 and S0-5 are `[x]` in `docs/project-todo-v6.md`, and S1 has its own prompt
at `docs/AGENT-PROMPT-v6-S1.md`. **Nothing above is a live instruction.**
