Files
template-app/modules/knowledge/contract/statuses.ts
T
2026-11-14 09:56:45 +00:00

54 lines
2.2 KiB
TypeScript

// The statuses a knowledge document moves through. `unavailable` and `disabled` are not rows: they
// are the module's and the service's answers, and the UI maps all eight states from what a page
// reads (the module flag, the service readiness, the document row).
export const DOCUMENT_STATUSES = ["queued", "indexing", "indexed", "failed", "cancelled"] as const
export type DocumentStatus = (typeof DOCUMENT_STATUSES)[number]
/** The search backend a deployment binds: the platform's managed service, and no other (ADR-061). */
export const KNOWLEDGE_BACKENDS = ["platform"] as const
export type KnowledgeBackend = (typeof KNOWLEDGE_BACKENDS)[number]
/** The readiness states the search port answers (the managed toolset's readiness + unavailable). */
export const SERVICE_STATES = ["registered", "indexing", "ready", "degraded", "disabled", "unavailable"] as const
export type ServiceState = (typeof SERVICE_STATES)[number]
/** The enablement flow's typed refusal reasons, surfaced in the UI as states. */
export const ENABLEMENT_REASONS = ["plan_required", "feature_disabled", "quota_exhausted"] as const
export type EnablementReason = (typeof ENABLEMENT_REASONS)[number]
/**
* Why the platform's knowledge service will not serve this deployment, as the pages show it. The service's
* reason codes reach the module as these (adapters/refusals.ts): `scope_missing` is the service refusing
* the deployment's token, whose `conusai.json` asks for `knowledge.collections:use`.
*/
export const KNOWLEDGE_REFUSALS = [
"plan_required",
"feature_disabled",
"quota_exhausted",
"budget_exhausted",
"scope_missing",
"indexing",
"approval_required",
"runtime_unavailable",
"configuration_missing",
] as const
export type KnowledgeRefusal = (typeof KNOWLEDGE_REFUSALS)[number]
/** The indexing failure codes a document row records: the file's own, and a refusal waiting cannot fix. */
export const INDEX_FAILURES = [
"processing_exhausted",
"configuration_missing",
"not_indexable",
"too_large",
"not_text",
"file_changed",
"plan_required",
"feature_disabled",
"quota_exhausted",
"budget_exhausted",
"scope_missing",
"approval_required",
] as const
export type IndexFailure = (typeof INDEX_FAILURES)[number]