Skip to content

feat(knowledge_base): add archestra_knowledge_base resource - #96

Open
priyanshu0x wants to merge 1 commit into
archestra-ai:mainfrom
priyanshu0x:feat/archestra-knowledge-base
Open

priyanshu0x wants to merge 1 commit into
archestra-ai:mainfrom
priyanshu0x:feat/archestra-knowledge-base

Conversation

@priyanshu0x

Copy link
Copy Markdown
Contributor

Closes #95.

Summary

  • Adds archestra_knowledge_base (CRUD + Import) mapping to POST/GET/PUT/DELETE /api/knowledge-bases.
  • Un-excludes the Knowledge Bases OpenAPI tag in oapi-config.yaml and regenerates internal/client/archestra_client.go.
  • Updates the bring-up-order guide + the basic/complete example modules to demonstrate the new resource.

Design notes

  • Wire body is RFC 7396 merge-patch, sharing one AttrSpec table for both Create and Update. Both endpoints declare every body field optional (Create: name required + description optional; Update: both optional with description: z.string().nullable().optional()), so a plan-null on description sends an explicit null and the backend clears the field.
  • name validated with LengthAtLeast(1) to mirror the backend's z.string().min(1). No upper bound — the underlying text column has none.
  • mapKnowledgeBaseResponse is shared across Get/Create/Update JSON200 payloads — they are structurally identical anonymous structs (openapi_types.UUID is a type alias of uuid.UUID, so Go's type-identity rule holds).
  • status is Computed-only — UpdateKnowledgeBaseSchema picks it but the PUT body schema does not, so it is purely backend-managed (defaults to active).
  • KnownIntentionallySkipped covers organizationId only; the API key authenticates the org and surfacing the field would create a phantom diff against the resource's implicit scoping.

Models the org-scoped knowledge base entity backing
POST/GET/PUT/DELETE on /api/knowledge-bases. Documents are grouped
inside a knowledge base and exposed to agents via the agent's
knowledge_base_ids attribute.

The merge-patch (RFC 7396) wire body covers both Create and Update —
both endpoints declare every body field optional (Create accepts
`name` required + `description` optional; Update accepts both as
optional, with `description: z.string().nullable().optional()` so
omitting it from config sends an explicit null and clears the
backend field).

Schema:
  - `name` Required, `LengthAtLeast(1)` mirroring the backend's
    `z.string().min(1)` (no upper bound — the underlying `text`
    column has none).
  - `description` Optional, nullable round-trip preserved.
  - `status`, `created_at`, `updated_at` Computed; `status` is
    backend-managed (UpdateKnowledgeBaseSchema picks it but the
    PUT route's body schema does not, so user-side mutation is
    not surfaced).

`mapKnowledgeBaseResponse` is shared across the Get/Create/Update
JSON200 payloads — they're structurally identical anonymous
structs (Go's type-identity rule treats `openapi_types.UUID` as
the same as `uuid.UUID` via type alias).

Tests cover Create + Read + Update + Import, idempotent re-apply
(ExpectEmptyPlan pin against Read-side state drift), nullable
description clear, and `name = ""` plan-time rejection.

Un-excludes the `Knowledge Bases` OpenAPI tag in oapi-config.yaml
and regenerates internal/client. Bring-up-order guide updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add archestra_knowledge_base resource

1 participant