Expand description
Corpus-management capability: list/inspect/import/delete corpora as screens + API.
Follows the symmetry contract — one shared CorpusDto renders as JSON for agents and (later)
as HTML for humans. Handlers live here; the app is assembled in crate::frontend::server.
This is the first capability drained out of the binary’s legacy routes; more land per increment.
Structs§
- Activate
Form - Fields of the human “Activate a service” form on the corpus screen.
- Corpus
Detail Dto - A corpus with its activated services and their status counts.
- Corpus
Dto - A corpus as exposed over the API/UI.
nameis the stable external handle used by every route. - Deactivate
Form - Fields of the human per-service “Deactivate” form: the service echoed as confirmation.
- Delete
Form - Fields of the human “Delete corpus” form: the name echoed as confirmation.
- Export
Form - Fields of the human “Export dataset” form (the web twin of
export_dataset). - Export
Request - Request body for exporting a corpus/service’s converted HTML into ZIP archives
(
export_dataset). Mirrors thecortex export-datasetCLI flags. - Import
Form - Fields of the human “Add a corpus” form on the admin dashboard.
- Import
Request - Request body for registering and importing a corpus.
- Sandbox
Form - Fields of the human “Create a sandbox” form on the corpus page.
- Sandbox
Provenance Dto - Provenance of a sandbox corpus: the parent it was carved from and the carve predicate. Only
present on sandbox corpora (
nullfor ordinary corpora). - Sandbox
Request - Request body for carving a sandbox corpus out of a parent by a filter (Arm 5). Task-status
and message-severity are independent, intersecting dimensions (Model C);
category/whatnarrow the message filter, mirroring the report drill-down. - Service
Status Dto - Per-service status counts within a corpus (mirrors the progress report).
- Snapshot
AckDto - Acknowledgement for a save-snapshot: the
(corpus, service)frozen and how many per-task status rows were appended tohistorical_tasks.
Functions§
- activate_
service - Activates a registered
serviceon acorpus: creates a TODO task per imported document so the workers begin converting it. Token-gated via theActorguard (the run is attributed to the authenticated actor); the work runs as a background job — pollGET /api/jobs/<uuid>for the pending/done status.401without a valid token,404on an unknown corpus/service,409if the service is already registered on the corpus (registration is idempotent-neutral — no re-activation wipes existing results; use extend/rerun instead),202with the job handle on success. - activate_
service_ human - The human twin of
activate_service: the corpus screen’s “Activate a service” form. Gated by the signed-inAdminSessioncookie (anonymous → sign-in); spawns the activation job and redirects to/jobs.404on an unknown corpus/service. - api_
corpora - Lists all registered corpora (the agent twin of the overview screen).
- api_
corpus - Inspects a single corpus: its activated services and per-service status counts.
- corpus_
page - The corpus screen (HTML twin of
api_corpus): the services registered on a corpus.404if the corpus is unknown,503if the pool is exhausted. - create_
sandbox_ corpus - Carves a sandbox corpus from
<parent>by a message-condition filter and starts the job that populates it; returns202 Accepted+ the job handle to poll. Token-gated via theActorguard;401without a valid token,404if the parent is unknown,409if the sandbox name is taken. The sandbox is a first-class corpus an agent can then run/rerun to iterate a campaign. - create_
sandbox_ human - The human twin of
create_sandbox_corpus: the corpus page’s “Create a sandbox” form. Gated by the signed-inAdminSessioncookie; carves the sandbox off the request path and redirects to/jobs.404unknown parent,409name taken. - deactivate_
service - Deactivates (retires) a
servicefrom acorpus: deletes that pair’s tasks + log messages (the service definition and its work on other corpora are untouched — the symmetric counterpart ofactivate_service). Token-gated via theActorguard and confirmation-gated (?confirm=<service>, echoing the service name). Returns204on success,400if the confirmation doesn’t match,404if the corpus or service is unknown. - deactivate_
service_ human - The human twin of
deactivate_service: the corpus screen’s per-service “Deactivate” form. Gated by the signed-inAdminSessioncookie (anonymous → sign-in) and confirmation-gated (echoes the service name), then redirects back to the corpus page.400if the confirmation doesn’t match,404if unknown. - delete_
corpus - Deletes a corpus and all of its tasks and log messages. Token-gated via the
Actorguard (an unauthenticated wipe of a corpus must not be possible —401without a valid token) and double-guarded: the caller must also echo the corpus name via?confirm=<name>to proceed (prevents accidental wipes; the UI confirms the same way). Returns 204 on success, 400 if the confirmation does not match, 404 if unknown. - delete_
corpus_ human - The human twin of
delete_corpus: the corpus screen’s “Delete corpus” form. Gated by the signed-inAdminSessioncookie (anonymous → sign-in) and confirmation-gated (the form echoes the corpus name), then redirects to the overview.400if the confirmation doesn’t match,404if unknown. - export_
dataset - Exports a corpus/service’s already-converted HTML into ZIP archives off the shared filesystem as
an in-process background job (no conversion is run); returns
202 Accepted+ the job handle, which agents and humans poll viaGET /api/jobs/<uuid>. The agent twin ofcortex export-dataset(and the future web form), over the sameexport_html_datasetcore. Token-gated via theActorguard (it reads/dataand writes archives server-side);401without a valid token,404if the corpus or service is unknown,422for an invalidgroup_byor severity key (pre-flighted so a doomed export never starts). - export_
dataset_ human - The human twin of
export_dataset: the “Export dataset” form post. Gated by the signed-inAdminSessioncookie (anonymous → sign-in); spawns the background export via the shared [start_export] core and redirects to the job’s live-progress page. A failed submit re-renders the form with a friendly message + the values preserved (404 unknown corpus/service, 422 bad grouping / no severity). - export_
dataset_ page - The “Export dataset” screen (
GET /export/<c>/<s>): the human form that drives the same export ascortex export-datasetand the agentexport_dataset. Signed-in admins only (anonymous → sign-in). Pre-fills a default output path + the CLI’s default severity set. A sibling top-level path (like/runs/<c>/<s>,/history/<c>/<s>) so it never collides with the report ladder’s/corpus/<c>/<s>/<severity>rung. - extend_
corpus - Extends an existing corpus with newly-arrived entries; starts an in-process job and returns
202 Accepted+ the job handle. Token-gated via theActorguard;401without a valid token,404if the corpus is unknown. - extend_
corpus_ human - The human twin of
extend_corpus: the corpus screen’s “Re-scan for new entries” button. Gated by the signed-inAdminSessioncookie (anonymous → sign-in); spawns the extend job and redirects to/jobs.404if the corpus is unknown. - import_
corpus - Registers a corpus and starts an in-process import job; returns
202 Accepted+ the job handle. Agents and humans pollGET /api/jobs/<uuid>(or the progress page) for completion. Token-gated via theActorguard (creating a corpus + a filesystem import job is a consequential write);401without a valid token,409if the corpus name already exists,422if thepathis not a readable directory on the server. - import_
corpus_ human - The human twin of
import_corpus: the admin dashboard’s “Add a corpus” form. Gated by the signed-inAdminSessioncookie (no token typed in the form — an anonymous browser is redirected to sign-in); registers + imports the corpus off the request path and redirects to/jobs.409if the name is taken. - new_
corpus_ page - The “Add a corpus” form (
GET /corpora/new). Signed-in admins only (anonymous → sign-in). - overview_
page - The overview screen (HTML twin of
api_corpora): the table of registered corpora — the admin landing page.503if the pool is exhausted. - routes
- The route set for the corpus-management capability (API + human screens).
- snapshot_
tasks - Freezes the current per-task statuses of a
(corpus, service)intohistorical_tasks— the agent twin of the report screen’s “save snapshot” action (POST /savetasks/...), so an agent can capture a baseline before a rerun campaign and later diff against it (GET /api/runs/.../tasks). Token-gated via theActorguard; the snapshot is append-only (history stays immutable over the API — there is deliberately no snapshot delete/modify endpoint; pruning is a human-admin operation, seecrate::frontend::retention).401without a valid token,404on an unknown corpus/service,202with the appended-row count on success. Uses a fresh connection (not the request pool) since the snapshot is a single bulkINSERT … SELECTover every task and shouldn’t pin a pooled slot.