> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a task (with steps)

> Unlike the listing, this carries the task's `steps` — every one by default, or the newest N with `steps_limit`, where `steps_total` reports the true count.



## OpenAPI

````yaml https://raw.githubusercontent.com/pinecone-io/pinecone-api/refs/heads/main/2026-07/nexus_data_2026-07.oas.yaml get /tasks/{id}
openapi: 3.0.3
info:
  title: Nexus API
  description: >
    Nexus turns a set of sources into a queryable, self-improving knowledge
    base. A context is **sources + a manifest**: upload sources, **curate** them
    into a searchable index, then query it. The manifest, one validated JSON
    document, defines how the context indexes, retrieves and answers.


    Curate is explicit — nothing is queryable until you run it. `{slug}` accepts
    a context's slug or its UUID. Query with `POST /api/query`, one turn per
    call, and read the answer from `output[].content[].text`; multi-turn
    conversations are sessions. Tasks are project-owned at `/api/tasks`, not
    nested under contexts.
  contact:
    name: Pinecone Support
    url: https://support.pinecone.io
    email: support@pinecone.io
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 2026-07
servers:
  - url: https://{host}/api
    description: Your Nexus deployment host
    variables:
      host:
        default: api.example.com
        description: Host of your Nexus deployment.
security:
  - bearerAuth: []
  - apiKey: []
tags:
  - name: Auth
    description: Login and identity.
  - name: Project
    description: The active Pinecone project and its disclosure state.
  - name: Contexts
    description: A context is sources + a manifest. Curate it explicitly before querying.
  - name: Manifest
    description: Manifest templates and the per-context manifest.
  - name: Source Files
    description: >-
      Per-context source imports (upload, connector, public repo) and the source
      file tree.
  - name: Knowledge
    description: Read-only browse of curated knowledge (chunks + artifacts).
  - name: Curation
    description: Curate workflow trigger, curation ledger, and version-pin primitives.
  - name: Connectors
    description: >-
      Project-level links to external source providers (Box, ...). Linked via
      OAuth or an API key, then used to import source documents into a context.
  - name: Query
    description: >-
      The unified KnowQL Query API: run a query turn (`/query`), fetch a turn
      (`/queries/{id}`), inspect its trace, manage feedback, comparison flags,
      and multi-turn sessions (`/sessions`).
  - name: Tasks
    description: >-
      Top-level, project-owned task records for every workflow (optimize,
      curate, search, work, explore, profile, import, pack, restore, groom).
  - name: Task Files
    description: Read, list, and delete files from live or archived task containers.
paths:
  /tasks/{id}:
    get:
      tags:
        - Tasks
      summary: Get a task (with steps)
      description: >-
        Unlike the listing, this carries the task's `steps` — every one by
        default, or the newest N with `steps_limit`, where `steps_total` reports
        the true count.
      operationId: get_task
      parameters:
        - in: path
          name: id
          description: Task id.
          required: true
          schema:
            type: string
          style: simple
        - in: header
          name: X-Pinecone-Api-Version
          description: >-
            Date-based contract version, echoed back on the same header. Omit
            for the default (`2026-07`); send `unstable` for the in-development
            surface. An unrecognized value is rejected with `400
            unsupported_api_version`.
          schema:
            default: 2026-07
            x-enum:
              - 2026-07
              - unstable
            type: string
          style: simple
        - in: query
          name: steps_limit
          description: Return only this many trailing steps. Absent returns them all.
          schema:
            type: integer
            minimum: 0
          style: form
      responses:
        '200':
          description: The task
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TaskResponse:
      description: One task record — a single run of a workflow, owned by the project.
      type: object
      properties:
        id:
          description: Task id.
          type: string
        project_id:
          description: The Pinecone project that owns the task.
          type: string
        context_id:
          nullable: true
          description: >-
            The context the run acts on. Null for a task that belongs to no
            context.
          type: string
        agent_id:
          nullable: true
          description: Reserved. Null on every task this version serves.
          type: string
        session_id:
          nullable: true
          description: Set for query turns
          type: string
        created_by:
          description: Principal that started the run.
          type: string
        workflow:
          $ref: '#/components/schemas/Workflow'
        state:
          $ref: '#/components/schemas/TaskState'
        error:
          nullable: true
          description: Failure detail. Set on a `failed` task.
          type: string
        input:
          $ref: '#/components/schemas/TaskInput'
        output:
          $ref: '#/components/schemas/TaskOutput'
        steps:
          description: >-
            Populated only on GET /tasks/{id}. May be a trailing window when
            `steps_limit` was given, so read the count from `steps_total` rather
            than this array's length.
          type: array
          items:
            $ref: '#/components/schemas/TaskStep'
        steps_total:
          description: >-
            True number of recorded steps. Absent on a read that carries no
            steps.
          type: integer
          format: int64
        tokens_prompt:
          description: Input tokens the run has billed so far.
          type: integer
          format: int64
        tokens_completion:
          description: Output tokens the run has billed so far.
          type: integer
          format: int64
        runtime_seconds:
          description: Seconds the container has been running.
          type: integer
          format: int64
        running_from:
          nullable: true
          description: When the container started. Null before it does.
          type: string
          format: date-time
        timeout_seconds:
          nullable: true
          description: Runtime budget for this task. Null when it runs uncapped.
          type: integer
        timeout_at:
          nullable: true
          description: When the budget expires and the run is terminated.
          type: string
          format: date-time
        archived_at:
          nullable: true
          description: When the task's files were archived. Null while they are still live.
          type: string
          format: date-time
        created_at:
          description: When the task row was created.
          type: string
          format: date-time
        last_activity_at:
          nullable: true
          description: When the runtime last reported anything. Drives stall detection.
          type: string
          format: date-time
        schedule:
          nullable: true
          description: >-
            Cron expression this run was scheduled from. Null for an on-demand
            run.
          type: string
        scheduled_at:
          nullable: true
          description: When a `scheduled` task is due to start.
          type: string
          format: date-time
        parent_task_id:
          nullable: true
          description: The task that spawned this one, as an optimize spawns its curates.
          type: string
        progress:
          $ref: '#/components/schemas/TaskProgress'
      required:
        - id
        - project_id
        - created_by
        - workflow
        - state
        - input
        - steps
        - tokens_prompt
        - tokens_completion
        - runtime_seconds
        - created_at
    Error:
      description: The error envelope every non-2xx response uses.
      type: object
      properties:
        message:
          description: >-
            Human-readable explanation. Not stable — branch on `code`, not on
            this.
          type: string
        code:
          description: >-
            Stable machine-readable code, present only on errors a client must
            branch on. 
          x-enum:
            - unsupported_api_version
            - preview_not_enabled
            - preview_file_limit
            - preview_byte_limit
            - workspace_host_required
            - workspace_not_found
          type: string
      required:
        - message
    Workflow:
      description: The canonical workflow name.
      x-enum:
        - optimize
        - curate
        - search
        - search_cc
        - search_rag
        - work
        - explore
        - profile
        - import
        - pack
        - restore
        - groom
      type: string
    TaskState:
      description: >-
        Where the run has got to. `scheduled` waits for its due time; `starting`
        and `provisioning` are a container being claimed and built; `running` is
        the work happening; `stopping` is a termination in progress.
        `completed`, `cancelled` and `failed` are terminal.
      x-enum:
        - scheduled
        - starting
        - provisioning
        - running
        - stopping
        - completed
        - cancelled
        - failed
      type: string
    TaskInput:
      description: >-
        A task's per-workflow `input`. It carries no discriminant of its own —
        the sibling `workflow` field selects the shape.
      anyOf:
        - $ref: '#/components/schemas/SearchInput'
        - $ref: '#/components/schemas/CurateInput'
        - $ref: '#/components/schemas/ImportInput'
        - $ref: '#/components/schemas/PackInput'
        - $ref: '#/components/schemas/RestoreInput'
        - $ref: '#/components/schemas/ExploreInput'
        - $ref: '#/components/schemas/ProfileInput'
        - $ref: '#/components/schemas/OptimizeInput'
        - $ref: '#/components/schemas/GroomInput'
    TaskOutput:
      nullable: true
      description: >-
        A task's reported `output`. Every workflow reports a different per-state
        shape, matched to a named variant only when its key set is exactly that
        variant's; anything else is preserved as stored. Treat this union as
        open. Null until the run reports anything.
      anyOf:
        - $ref: '#/components/schemas/SearchTurnCompletedOutput'
        - $ref: '#/components/schemas/SearchCcTurnCompletedOutput'
        - $ref: '#/components/schemas/SearchTurnFailedOutput'
        - $ref: '#/components/schemas/PackRunningOutput'
        - $ref: '#/components/schemas/PackCompletedOutput'
        - $ref: '#/components/schemas/RestoreRunningOutput'
        - $ref: '#/components/schemas/RestoreCompletedOutput'
        - $ref: '#/components/schemas/OptimizeResultOutput'
        - $ref: '#/components/schemas/OptimizeNoopOutput'
        - $ref: '#/components/schemas/GroomMetricsOutput'
        - $ref: '#/components/schemas/CurateRunOutput'
        - $ref: '#/components/schemas/CurateManifestTuneOutput'
        - $ref: '#/components/schemas/CurateNoopOutput'
        - $ref: '#/components/schemas/ExploreOutput'
        - $ref: '#/components/schemas/ProfileEstimateOutput'
        - $ref: '#/components/schemas/ProfileEmptyOutput'
        - $ref: '#/components/schemas/ImportOutput'
        - $ref: '#/components/schemas/StatusErrorOutput'
        - $ref: '#/components/schemas/StateFailedOutput'
        - $ref: '#/components/schemas/ErrorOutput'
        - title: Other
          description: Any shape without a named variant
          type: object
          additionalProperties: true
    TaskStep:
      description: >-
        One reported step row. `step_id` and `status` are always set; the rest
        are per-workflow optionals, so an absent key stays absent.
      type: object
      properties:
        step_id:
          description: Identifies the step within the task.
          type: string
        status:
          description: How the step ended, e.g. `running` or `completed`.
          type: string
        type:
          description: What kind of step this is; the vocabulary is per-workflow.
          type: string
        content:
          description: The step's reported text payload.
          type: string
        commentary:
          description: The runtime's one-line account of what the step is doing.
          type: string
        code:
          description: Redacted tool input (search)
          type: string
        result:
          description: Redacted tool output (search)
          type: string
        cum_input_tokens:
          description: Task-to-date input tokens, including this step.
          type: integer
          format: int64
        cum_output_tokens:
          description: Task-to-date output tokens, including this step.
          type: integer
          format: int64
        job_id:
          description: Identifier of the LlamaParse job doing the work.
          type: string
        path:
          description: Source path being parsed
          type: string
      required:
        - step_id
        - status
    TaskProgress:
      description: >-
        Coarse run progress, written by the runtime. Absent on a task that
        reports none.
      type: object
      properties:
        phase:
          description: 1-based index of the phase now running.
          type: integer
          format: int64
        phases:
          description: Total phases this run expects.
          type: integer
          format: int64
        label:
          description: What the current phase is doing.
          type: string
        pct:
          description: Completion across the whole run, 0–100.
          type: number
          format: double
        eta_seconds:
          nullable: true
          description: Estimated seconds remaining. Null when the run cannot estimate one.
          type: integer
          format: int64
      required:
        - phase
        - phases
        - label
        - pct
    SearchInput:
      title: Search / search_cc / search_rag / work
      description: >-
        One shape for the whole search family — the same payload is written
        whichever of them a turn resolves to.
      type: object
      properties:
        session_id:
          description: The session the turn runs in.
          type: string
        query_id:
          description: The turn this task serves.
          type: string
        ask:
          description: >-
            Title fallback for the tasks UI; empty when the turn had no user
            message
          type: string
        messages:
          description: The conversation history handed to the runtime.
          type: array
          items:
            description: One message of history.
            type: object
            properties:
              role:
                description: Who sent it, e.g. `user`.
                type: string
              content:
                description: The message text.
                type: string
            required:
              - role
              - content
        models:
          description: The session's model fallback list, in preference order.
          type: array
          items:
            description: A catalog model id or tier name.
            type: string
        tools:
          description: Tool names the turn may call.
          type: array
          items:
            description: A tool name.
            type: string
        shape:
          nullable: true
          description: JSON Schema the answer must conform to. Null on a free-text turn.
          type: object
          additionalProperties: true
        instructions:
          nullable: true
          description: The session's system prompt. Null when none was pinned.
          type: string
        scope:
          description: Context ids the turn searches.
          type: array
          items:
            description: A context id the turn searched.
            type: string
        turn_timeout_seconds:
          description: Runtime budget for this one turn.
          type: integer
          format: int64
        retrieval:
          description: The turn's retrieval controls.
          type: object
          properties:
            retrieval_only:
              nullable: true
              description: >-
                Skip synthesis and return the hits. Null where the caller
                omitted it.
              type: boolean
            pointers_only:
              nullable: true
              description: >-
                Skip synthesis and return pointers only. Null where the caller
                omitted it.
              type: boolean
            chunks_only:
              nullable: true
              description: Narrow retrieval to chunks. Null where the caller omitted it.
              type: boolean
            artifacts_only:
              nullable: true
              description: Narrow retrieval to artifacts. Null where the caller omitted it.
              type: boolean
            max_retrieved:
              nullable: true
              description: Cap on retrieved items. Null where the caller omitted it.
              type: integer
              format: int64
            max_retrieved_chars:
              nullable: true
              description: Cap on per-item text length. Null where the caller omitted it.
              type: integer
              format: int64
            compose:
              nullable: true
              description: >-
                Whether to synthesize an answer. Null where the caller omitted
                it.
              type: boolean
            max_steps:
              nullable: true
              description: >-
                Cap on the agent's tool-loop steps. Null where the caller
                omitted it.
              type: integer
              format: int64
            thinking_level:
              nullable: true
              description: Reasoning depth. Null where the caller omitted it.
              x-enum:
                - minimal
                - low
                - medium
                - high
              type: string
          required:
            - retrieval_only
            - pointers_only
            - chunks_only
            - artifacts_only
            - max_retrieved
            - max_retrieved_chars
            - compose
            - max_steps
            - thinking_level
        comparison_group:
          nullable: true
          description: The Compare run this turn belongs to. Null on a normal single query.
          type: string
      required:
        - session_id
        - query_id
        - ask
        - messages
        - models
        - tools
        - shape
        - instructions
        - scope
        - turn_timeout_seconds
        - comparison_group
    CurateInput:
      title: Curate
      description: What a curate run was started with.
      type: object
      properties:
        trigger:
          description: >-
            What started the run, e.g. `manual`, `reconcile`, `restore`, or
            `resume`.
          type: string
        force:
          description: Full rebuild rather than incremental.
          type: boolean
        scope:
          description: What the run covered, e.g. `full`, `reconcile`, or `restore`.
          type: string
        batch_size:
          description: Sources processed per batch.
          type: integer
        models:
          description: Model-id overrides for the curate runtime.
          type: array
          items:
            description: A catalog model id or tier name.
            type: string
        legs:
          description: >-
            Set to `["chunks"]` to gate the run to the chunk + keyword indices,
            skipping artifact extraction.
          type: array
          items:
            description: A leg name, e.g. `chunks`.
            type: string
        artifacts_reset:
          description: Drop the existing artifacts and re-extract from scratch.
          type: boolean
        skip_corpus_aggregation:
          description: >-
            Skip the corpus-wide artifact pass, leaving only per-document
            extraction.
          type: boolean
        claimed_version:
          description: What a drained predecessor had already reserved.
          type: integer
          format: int64
      required:
        - trigger
        - force
        - scope
    ImportInput:
      title: Import
      description: >-
        One of three disjoint shapes, discriminated by which of `connector_id` /
        `url` / `raw_archive_key` is present.
      anyOf:
        - title: Connector import
          description: Sources pulled from a linked project connector.
          type: object
          properties:
            provider:
              description: The connector's provider, e.g. `box`.
              type: string
            connector_id:
              description: The linked connector the sources came from.
              type: string
            folder:
              nullable: true
              description: Connector folder imported. Null on a file-list import.
              type: string
            item_type:
              description: Whether `folder` or `files` selected the sources.
              x-enum:
                - folder
                - file
              type: string
            files:
              description: Connector file ids imported. Empty on a folder import.
              type: array
              items:
                description: A connector file id.
                type: string
            path:
              description: Subdirectory under the source tree the import landed in.
              type: string
            limits:
              $ref: '#/components/schemas/ImportLimits'
          required:
            - provider
            - connector_id
            - item_type
            - files
            - path
        - title: Public-repo import
          description: Sources fetched from a public URL.
          type: object
          properties:
            provider:
              description: The public-source provider, e.g. `github`.
              type: string
            url:
              description: The public repository or archive fetched.
              type: string
            path:
              description: Subdirectory under the source tree the import landed in.
              type: string
            limits:
              $ref: '#/components/schemas/ImportLimits'
          required:
            - provider
            - url
            - path
        - title: Archive upload
          description: Sources expanded from an uploaded archive.
          type: object
          properties:
            raw_archive_key:
              description: Staging key under the source bucket's `_inbox/` prefix
              type: string
            path:
              description: Subdirectory under the source tree the import landed in.
              type: string
            limits:
              $ref: '#/components/schemas/ImportLimits'
          required:
            - raw_archive_key
            - path
    PackInput:
      title: Pack
      description: What a pack run was started with.
      type: object
      properties:
        include_traces:
          description: Whether query traces were packed alongside sources and knowledge.
          type: boolean
        slug:
          description: Slug of the packed context; names the output archive.
          type: string
        context_id:
          description: The context that was packed.
          type: string
      required:
        - include_traces
        - slug
        - context_id
    RestoreInput:
      title: Restore
      description: What a restore run was started with.
      type: object
      properties:
        pack_key:
          description: Object-store key of the pack being restored.
          type: string
        pack_filename:
          description: The pack archive's file name.
          type: string
        target_context_id:
          description: The already-created context the pack is restored into.
          type: string
        target_slug:
          description: URL-safe name of the context being written into.
          type: string
        target_name:
          description: Human-readable label of the context being written into.
          type: string
        sample_queries:
          description: >-
            Sample queries to seed the target with, taken from the pack. Absent
            on a pack that carried none.
          type: array
          items:
            description: One sample query carried over from the pack.
            type: string
      required:
        - pack_key
        - pack_filename
        - target_context_id
        - target_slug
        - target_name
    ExploreInput:
      title: Explore
      description: What an explore run was started with.
      type: object
      properties:
        guide:
          description: Guidance the proposal was steered with. Empty when none was given.
          type: string
        trigger:
          description: What started the run, e.g. `manual`.
          type: string
      required:
        - guide
        - trigger
    ProfileInput:
      title: Profile
      description: What a profile run was started with.
      type: object
      properties:
        manifest:
          description: The candidate manifest the run profiles, not a stored one.
          allOf:
            - $ref: '#/components/schemas/Manifest'
        trigger:
          description: What started the run, e.g. `manual`.
          type: string
      required:
        - manifest
        - trigger
    OptimizeInput:
      title: Optimize
      description: >-
        Only the keys the trigger request supplied are written, so an input with
        no keys is a valid no-op optimize.
      type: object
      properties:
        candidate_queries:
          description: The queries the run tunes toward. Absent makes the run a no-op.
          type: array
          items:
            $ref: '#/components/schemas/CandidateQuery'
        eval_pass_rate_threshold:
          description: Pass rate an iteration must clear to count as ready.
          type: number
          format: double
        retrieval_p90_latency_ms:
          description: The p90 latency bar an iteration must stay under.
          type: integer
          format: int64
        optimize_timeout_seconds:
          description: Runtime budget for the whole optimize.
          type: integer
          format: int64
        max_tool_turns:
          description: Cap on tool-loop turns per eval query.
          type: integer
        max_iterations:
          description: Cap on candidate manifests tried.
          type: integer
        models:
          description: Tier names or catalog ids, in preference order.
          type: array
          items:
            description: A tier name or catalog id.
            type: string
    GroomInput:
      title: Groom
      description: What a groom run was started with.
      type: object
      properties:
        budget:
          description: Cap on fact batches the run consolidates.
          type: integer
        groom_timeout_seconds:
          description: Runtime budget for the whole groom.
          type: integer
          format: int64
        models:
          description: Tier names or catalog ids, in preference order.
          type: array
          items:
            description: A tier name or catalog id.
            type: string
    SearchTurnCompletedOutput:
      title: Search / search_rag completed
      description: >-
        What a finished search turn's task reports. The turn itself, with its
        steps and structured citations, is at `GET /queries/{query_id}`.
      type: object
      properties:
        status:
          description: How the turn ended.
          type: string
        query_id:
          description: The turn this task answered.
          type: string
        answer:
          description: The answer text.
          type: string
        output_json:
          nullable: true
          description: >-
            Structured answer when the turn carried a shape, or the hits on a
            retrieval-only turn. Absent otherwise.
          type: object
          additionalProperties: true
        citations:
          description: Cited source paths. The turn carries the structured form.
          type: array
          items:
            description: A cited source path.
            type: string
        latency_ms:
          description: Wall time for the turn.
          type: integer
          format: int64
        unknown_models:
          description: >-
            Model selections dropped as unknown before dispatch, so a caller
            whose pin was silently ignored can see it. Absent when nothing was
            dropped.
          type: array
          items:
            description: >-
              A requested model id or tier name the project's catalog does not
              carry.
            type: string
      required:
        - status
        - query_id
        - answer
        - citations
        - latency_ms
    SearchCcTurnCompletedOutput:
      title: Search-as-code completed
      description: >-
        The search-as-code path reports a step count where the others report
        `output_json`.
      type: object
      properties:
        status:
          description: How the turn ended.
          type: string
        query_id:
          description: The turn this task answered.
          type: string
        answer:
          description: The answer text.
          type: string
        citations:
          description: Cited source paths.
          type: array
          items:
            description: A cited source path.
            type: string
        latency_ms:
          description: Wall time for the turn.
          type: integer
          format: int64
        steps:
          description: Reasoning steps the turn ran.
          type: integer
          format: int64
      required:
        - status
        - query_id
        - answer
        - citations
        - latency_ms
        - steps
    SearchTurnFailedOutput:
      title: Search failed
      description: What a search turn reports when it could not answer.
      type: object
      properties:
        status:
          description: How the turn ended.
          type: string
        query_id:
          description: The turn that failed.
          type: string
        error:
          description: Why the turn failed.
          type: string
      required:
        - status
        - query_id
        - error
    PackRunningOutput:
      title: Pack running
      description: >-
        A pack's progress: the initial claim, the enrichment pass, then periodic
        write progress, each adding to what came before. `state` is `running` on
        all of them, so key presence is what tells them apart.
      type: object
      properties:
        state:
          description: >-
            Always `running`. Which report this is shows in the keys it carries,
            not here.
          x-enum:
            - running
          type: string
        slug:
          description: Slug of the context being packed.
          type: string
        include_traces:
          description: >-
            Whether query traces are being packed. Absent on the write-progress
            report.
          type: boolean
        started_at:
          description: When the pack started. Absent on the write-progress report.
          type: string
        sources_total:
          description: Source files to be packed. Absent until the inventory is counted.
          type: integer
          format: int64
        knowledge_total:
          description: >-
            Curated knowledge files to be packed. Absent until the inventory is
            counted.
          type: integer
          format: int64
        traces_total:
          description: Trace blobs to be packed. Absent until the inventory is counted.
          type: integer
          format: int64
        bytes_collected:
          description: Bytes read so far. Absent until the inventory is counted.
          type: integer
          format: int64
        enriching:
          description: Present while the LLM writes the pack's summary.
          type: boolean
        files_written:
          description: >-
            Files written into the archive so far. Present only once writing has
            begun.
          type: integer
          format: int64
      required:
        - state
        - slug
    PackCompletedOutput:
      title: Pack completed
      description: >-
        The archive is written. Download it from `GET
        /tasks/{id}/files/read/{pack_filename}`.
      type: object
      properties:
        state:
          description: Which stage of the pack this report describes.
          type: string
        pack_filename:
          description: Name of the written archive, `<slug>.context.zip`.
          type: string
        pack_size:
          description: Byte size of the archive.
          type: integer
          format: int64
        sources_files:
          description: How many corpus documents went into the archive.
          type: integer
          format: int64
        knowledge_files:
          description: How many curated documents went into the archive.
          type: integer
          format: int64
        traces_included:
          description: Whether query traces were included.
          type: boolean
        traces_files:
          description: Trace blobs packed.
          type: integer
          format: int64
        corpus_groups_included:
          description: Corpus groups carried over from the curation ledger.
          type: integer
          format: int64
        started_at:
          description: When the pack started.
          type: string
        completed_at:
          description: When the pack finished.
          type: string
        details:
          $ref: '#/components/schemas/PackDetails'
      required:
        - state
        - pack_filename
        - pack_size
        - sources_files
        - knowledge_files
        - traces_included
        - traces_files
        - corpus_groups_included
        - started_at
        - completed_at
        - details
    RestoreRunningOutput:
      title: Restore running
      description: >-
        A restore's progress: the initial claim, the fetch, the unzip, then
        periodic staging. `state` is `running` on all four, so key presence is
        what tells them apart, and only `state` is on every one.
      type: object
      properties:
        state:
          description: >-
            Always `running`. Which report this is shows in the keys it carries,
            not here.
          x-enum:
            - running
          type: string
        pack_filename:
          description: The pack archive's file name. Absent on the staging report.
          type: string
        pack_size:
          description: Byte size of the pack archive. Present once it has been fetched.
          type: integer
          format: int64
        target_context_id:
          description: The context the pack is restored into. Absent on the staging report.
          type: string
        target_slug:
          description: >-
            Slug of that target context. Absent from the unzip and staging
            reports.
          type: string
        started_at:
          description: When the restore started. Present on the first report only.
          type: string
        stage_progress:
          description: >-
            How far the current phase has got. Absent on the first report,
            before any phase begins.
          allOf:
            - $ref: '#/components/schemas/StageProgress'
        sources_count:
          description: Source files found in the pack. Present once it has been expanded.
          type: integer
          format: int64
        knowledge_count:
          description: >-
            Knowledge files found in the pack. Present once it has been
            expanded.
          type: integer
          format: int64
      required:
        - state
    RestoreCompletedOutput:
      title: Restore completed
      description: >-
        The target holds the pack's sources, knowledge, and manifest. Its index
        stays empty until curated.
      type: object
      properties:
        state:
          description: Which stage of the restore this report describes.
          type: string
        pack_filename:
          description: The pack archive's file name.
          type: string
        pack_size:
          description: How large the archive is on disk.
          type: integer
          format: int64
        target_context_id:
          description: The context the pack is restored into.
          type: string
        target_slug:
          description: URL-safe name of the context being written into.
          type: string
        sources_staged:
          description: Source files written into the target.
          type: integer
          format: int64
        knowledge_staged:
          description: Knowledge files written into the target.
          type: integer
          format: int64
        manifest_set:
          description: Whether the pack's manifest was pinned onto the target.
          type: boolean
        corpus_groups_set:
          description: Corpus groups written into the target's curation ledger.
          type: integer
          format: int64
        sample_queries:
          description: >-
            Sample queries carried from the pack onto the target. Empty when the
            pack had none.
          type: array
          items:
            description: One sample query set on the target.
            type: string
        started_at:
          description: When the restore started.
          type: string
        completed_at:
          description: When the restore finished.
          type: string
      required:
        - state
        - pack_filename
        - pack_size
        - target_context_id
        - target_slug
        - sources_staged
        - knowledge_staged
        - manifest_set
        - corpus_groups_set
        - sample_queries
        - started_at
        - completed_at
    OptimizeResultOutput:
      title: Optimize result
      description: What the tuning loop settled on.
      type: object
      properties:
        status:
          description: >-
            Set to `ready` only when the best iteration cleared both the
            pass-rate and latency bars.
          type: string
        best_score:
          description: Eval pass rate the best iteration scored, 0–1.
          type: number
          format: double
        best_iteration:
          description: Which iteration scored it.
          type: integer
          format: int64
        best_latency_ok:
          description: Whether that iteration also stayed under the latency bar.
          type: boolean
        total_iterations:
          description: Candidate manifests tried.
          type: integer
          format: int64
        pass_rate_threshold:
          description: The pass-rate bar the run measured against.
          type: number
          format: double
        p90_latency_limit_ms:
          nullable: true
          description: The p90 latency bar. Null when latency was not gated.
          type: number
          format: double
        elapsed_seconds:
          description: Wall time for the whole loop.
          type: number
          format: double
        usage:
          $ref: '#/components/schemas/ChatUsage'
        models:
          description: Tier → resolved model id.
          type: object
          additionalProperties:
            description: The model id the tier resolved to.
            type: string
        unknown_models:
          description: >-
            Model selections dropped as unknown before dispatch, so a caller
            whose pin was silently ignored can see it. Absent when nothing was
            dropped.
          type: array
          items:
            description: >-
              A requested model id or tier name the project's catalog does not
              carry.
            type: string
        manifest:
          description: >-
            The tuned manifest persisted onto the context when the task
            completes.
          allOf:
            - $ref: '#/components/schemas/Manifest'
        changed_legs:
          description: >-
            Which manifest legs the tuning changed, so a re-curate can be scoped
            to them.
          type: array
          items:
            description: A manifest leg the tuning changed.
            type: string
      required:
        - status
        - best_score
        - best_iteration
        - best_latency_ok
        - total_iterations
        - pass_rate_threshold
        - p90_latency_limit_ms
        - elapsed_seconds
        - usage
        - models
        - manifest
        - changed_legs
    OptimizeNoopOutput:
      title: Optimize no-op
      description: Too few candidate queries or problems to tune from.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        reason:
          description: Which gate the run stopped at.
          type: string
        candidate_queries:
          description: Candidate queries the run was given.
          type: integer
          format: int64
        problems:
          description: How many of those counted as problems worth tuning for.
          type: integer
          format: int64
      required:
        - status
        - reason
        - candidate_queries
        - problems
    GroomMetricsOutput:
      title: Groom
      description: >-
        What a groom run consolidated. Groom is to a work context what curate is
        to a search context — it distills facts out of accumulated work traces
        into artifacts.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        budget:
          description: Fact batches the run was allowed to consume.
          type: integer
          format: int64
        batches_staged:
          description: Batches available to consume.
          type: integer
          format: int64
        batches_consumed:
          description: Batches actually consumed, capped by `budget`.
          type: integer
          format: int64
        facts_distilled:
          description: Facts extracted from the consumed batches.
          type: integer
          format: int64
        facts_added:
          description: Distilled facts that were new.
          type: integer
          format: int64
        facts_merged:
          description: Distilled facts folded into a fact already held.
          type: integer
          format: int64
        facts_dropped_untyped:
          description: Facts discarded because they matched no declared artifact type.
          type: integer
          format: int64
        edges_added:
          description: New relationships recorded between artifacts.
          type: integer
          format: int64
        artifacts_pruned:
          description: Artifacts removed as superseded.
          type: integer
          format: int64
        artifact_files_written:
          description: How many were written.
          type: integer
          format: int64
        artifact_files_deleted:
          description: How many were removed.
          type: integer
          format: int64
        artifact_count:
          description: Artifacts the context holds after the run.
          type: integer
          format: int64
        artifact_bytes:
          description: Total artifact size after the run.
          type: integer
          format: int64
        duration_ms:
          description: Wall time for the groom.
          type: integer
          format: int64
      required:
        - status
        - budget
        - batches_staged
        - batches_consumed
        - facts_distilled
        - facts_added
        - facts_merged
        - facts_dropped_untyped
        - edges_added
        - artifacts_pruned
        - artifact_files_written
        - artifact_files_deleted
        - artifact_count
        - artifact_bytes
        - duration_ms
    CurateRunOutput:
      title: Curate run
      description: >-
        What a curate run built. The index it wrote goes live only when
        `flipped` is true.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        flipped:
          description: >-
            Whether the new index version was made live. False means queries
            still read the previous one.
          type: boolean
        versioned:
          description: Whether the run wrote version stamps.
          type: boolean
        mode:
          description: >-
            Set to `incremental` when the context has a manifest, `full`
            otherwise.
          type: string
        scope:
          description: What the run covered, e.g. `full` or `reconcile`.
          type: string
        images_skipped_no_vision:
          description: Images left unread because the configured model cannot see.
          type: integer
          format: int64
        sources_skipped_unreadable:
          description: Sources no leg could read, skipped rather than failed.
          type: integer
          format: int64
        usage:
          $ref: '#/components/schemas/CurateUsage'
        sample_queries:
          description: Example questions the corpus can answer
          type: array
          items:
            description: One example question.
            type: string
        delta:
          description: What the run changed, counted per leg.
          type: object
          properties:
            new:
              description: Sources not seen by a previous curate.
              type: integer
              format: int64
            changed:
              description: Sources whose content hash moved.
              type: integer
              format: int64
            deleted:
              description: Sources dropped from the index.
              type: integer
              format: int64
            processed:
              description: Sources the run actually read.
              type: integer
              format: int64
            failed:
              description: Sources that could not be curated.
              type: integer
              format: int64
            failed_sources:
              description: Paths of the failed sources, capped in length.
              type: array
              items:
                description: A source path that failed.
                type: string
            failed_sources_truncated:
              description: >-
                Whether failed_sources was capped and the full list spilled to a
                file
              type: boolean
            failed_sources_file:
              description: Where the full failed-sources list was written when truncated
              type: string
            corpus_artifacts:
              description: Artifacts written by the corpus-wide reduce pass.
              type: integer
              format: int64
            corpus_edges:
              description: Edges written by that pass.
              type: integer
              format: int64
            corpus_artifacts_screened:
              description: Corpus artifacts rejected by the quality screen.
              type: integer
              format: int64
            screened:
              description: Sum of the per-leg and corpus screen counts
              type: integer
              format: int64
            chunks_created:
              description: Chunks written for the first time.
              type: integer
              format: int64
            chunks_updated:
              description: Chunks rewritten from changed sources.
              type: integer
              format: int64
            artifacts_created:
              description: Per-document artifacts written for the first time.
              type: integer
              format: int64
            artifacts_updated:
              description: Per-document artifacts rewritten from changed sources.
              type: integer
              format: int64
            chunks_screened:
              description: Chunks rejected by the quality screen.
              type: integer
              format: int64
            artifacts_screened:
              description: Per-document artifacts rejected by the quality screen.
              type: integer
              format: int64
            images_skipped_no_vision:
              description: Images left unread because the configured model cannot see.
              type: integer
              format: int64
            sources_skipped_unreadable:
              description: Sources no leg could read, skipped rather than failed.
              type: integer
              format: int64
            artifacts_errored:
              description: Extraction calls that failed outright.
              type: integer
              format: int64
            sources_content_truncated:
              description: >-
                Sources whose text was cut at the input cap, so their tail went
                unread.
              type: integer
              format: int64
          required:
            - new
            - changed
            - deleted
            - processed
            - failed
            - failed_sources
            - failed_sources_truncated
            - failed_sources_file
            - corpus_artifacts
            - corpus_edges
            - corpus_artifacts_screened
            - screened
            - chunks_created
            - chunks_updated
            - artifacts_created
            - artifacts_updated
            - chunks_screened
            - artifacts_screened
            - images_skipped_no_vision
            - sources_skipped_unreadable
            - artifacts_errored
            - sources_content_truncated
      required:
        - status
        - flipped
        - versioned
        - mode
        - scope
        - images_skipped_no_vision
        - sources_skipped_unreadable
        - usage
        - sample_queries
        - delta
    CurateManifestTuneOutput:
      title: Curate manifest_tune
      description: >-
        The post-optimize artifacts re-eval. Targets optimize trial namespaces,
        so `flipped` is always false and `mode` is always `manifest_tune`.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        flipped:
          description: >-
            Always false — the run targets optimize trial namespaces, not the
            live index.
          x-enum:
            - false
          type: boolean
        versioned:
          description: Whether the run wrote version stamps.
          type: boolean
        mode:
          description: Always `manifest_tune`.
          x-enum:
            - manifest_tune
          type: string
        usage:
          $ref: '#/components/schemas/CurateUsage'
        delta:
          description: What the re-eval changed.
          type: object
          properties:
            artifacts_reevaluated:
              description: >-
                Artifacts re-extracted under the tuned manifest. Replaces the
                source counts a normal run reports.
              type: integer
              format: int64
            failed:
              description: Sources that could not be re-evaluated.
              type: integer
              format: int64
            failed_sources:
              description: Paths of the failed sources, capped in length.
              type: array
              items:
                description: A source path that failed.
                type: string
            failed_sources_truncated:
              description: >-
                Whether failed_sources was capped and the full list spilled to a
                file.
              type: boolean
            failed_sources_file:
              description: Where the full failed-sources list was written when truncated.
              type: string
            corpus_artifacts:
              description: Artifacts written by the corpus-wide reduce pass.
              type: integer
              format: int64
            corpus_edges:
              description: Edges written by that pass.
              type: integer
              format: int64
            chunks_created:
              description: Chunks written for the first time.
              type: integer
              format: int64
            chunks_updated:
              description: Chunks rewritten from changed sources.
              type: integer
              format: int64
            artifacts_created:
              description: Per-document artifacts written for the first time.
              type: integer
              format: int64
            artifacts_updated:
              description: Per-document artifacts rewritten from changed sources.
              type: integer
              format: int64
            chunks_screened:
              description: Chunks rejected by the quality screen.
              type: integer
              format: int64
            artifacts_screened:
              description: Per-document artifacts rejected by the quality screen.
              type: integer
              format: int64
            images_skipped_no_vision:
              description: Images left unread because the configured model cannot see.
              type: integer
              format: int64
            sources_skipped_unreadable:
              description: Sources no leg could read, skipped rather than failed.
              type: integer
              format: int64
            artifacts_errored:
              description: Extraction calls that failed outright.
              type: integer
              format: int64
            sources_content_truncated:
              description: Sources whose text was cut at the input cap.
              type: integer
              format: int64
          required:
            - artifacts_reevaluated
            - failed
            - failed_sources
            - failed_sources_truncated
            - failed_sources_file
            - corpus_artifacts
            - corpus_edges
            - chunks_created
            - chunks_updated
            - artifacts_created
            - artifacts_updated
            - chunks_screened
            - artifacts_screened
            - images_skipped_no_vision
            - sources_skipped_unreadable
            - artifacts_errored
            - sources_content_truncated
      required:
        - status
        - flipped
        - versioned
        - mode
        - usage
        - delta
    CurateNoopOutput:
      title: Curate no-op
      description: >-
        Nothing changed since the last run; `delta` is the literal string
        `empty` rather than a count block, which is what makes this a shape of
        its own.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        flipped:
          description: Whether a new index version was made live.
          type: boolean
        versioned:
          description: Whether the run wrote version stamps.
          type: boolean
        mode:
          description: >-
            Set to `incremental` when the context has a manifest, `full`
            otherwise.
          type: string
        scope:
          description: What the run would have covered.
          type: string
        delta:
          description: Always the literal string `empty`.
          x-enum:
            - empty
          type: string
      required:
        - status
        - flipped
        - versioned
        - mode
        - scope
        - delta
    ExploreOutput:
      title: Explore
      description: >-
        What an explore run proposed. Persists nothing — apply it by writing the
        manifest and forcing a curate.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        matches:
          description: >-
            Validated template recommendations; unknown or low-confidence
            proposals are dropped upstream.
          type: array
          items:
            $ref: '#/components/schemas/TemplateMatch'
        none:
          description: True when no template fit
          type: boolean
        guide:
          description: The guidance the proposal was steered with, echoed back.
          type: string
        models:
          description: Tier → resolved model id.
          type: object
          additionalProperties:
            description: The model id the tier resolved to.
            type: string
        unknown_models:
          description: >-
            Model selections dropped as unknown before dispatch, so a caller
            whose pin was silently ignored can see it. Absent when nothing was
            dropped.
          type: array
          items:
            description: >-
              A requested model id or tier name the project's catalog does not
              carry.
            type: string
        usage:
          $ref: '#/components/schemas/ChatUsage'
      required:
        - status
        - matches
        - none
        - guide
        - models
        - usage
    ProfileEstimateOutput:
      title: Profile estimate
      description: >-
        An estimate of what curating the candidate manifest would cost,
        extrapolated from a sample of the corpus. Persists nothing.
      type: object
      properties:
        state:
          description: How the run ended.
          type: string
        g:
          description: >-
            Estimated distinct-artifact count with its uncertainty band. This is
            what drives the cost estimate, since extraction cost scales with it.
          type: object
          properties:
            value:
              description: Point estimate of the distinct-artifact count.
              type: integer
              format: int64
            lo:
              description: Low end of the band.
              type: integer
              format: int64
            hi:
              description: High end of the band.
              type: integer
              format: int64
            method:
              description: >-
                The estimator the recurrence blend selected; `empty` on the
                no-sample path
              type: string
            recurrence:
              description: >-
                How often the same subject recurs across sampled documents.
                Drives which estimator is chosen.
              type: number
              format: double
            confidence:
              description: Qualitative confidence in the estimate.
              type: string
            note:
              description: Caveat on how to read the estimate.
              type: string
          required:
            - value
            - lo
            - hi
            - method
            - recurrence
            - confidence
            - note
        density:
          description: Measured on the sampling window, not the full curate read-depth.
          type: object
          properties:
            entities_per_doc:
              description: Mean distinct subjects found per sampled document.
              type: number
              format: double
            avg_doc_chars:
              description: Mean source length in characters.
              type: integer
              format: int64
          required:
            - entities_per_doc
            - avg_doc_chars
        cost:
          description: >-
            Estimated token and time cost of the curate, one estimate per model
            tier.
          type: object
          properties:
            by_tier:
              description: One estimate per model tier.
              type: object
              properties:
                lite:
                  $ref: '#/components/schemas/ProfileTierCost'
                standard:
                  $ref: '#/components/schemas/ProfileTierCost'
                pro:
                  $ref: '#/components/schemas/ProfileTierCost'
              required:
                - lite
                - standard
                - pro
            default_tier:
              description: The tier the context's current `artifact_model` resolves to
              type: string
          required:
            - by_tier
            - default_tier
        sampling:
          description: >-
            How much of the corpus the profile actually read. The estimate is
            extrapolated from this much, so a small `fraction` means a wide
            band.
          type: object
          properties:
            n_total:
              description: Sources in the corpus.
              type: integer
              format: int64
            n_sampled:
              description: Sources the profile read.
              type: integer
              format: int64
            fraction:
              description: The `n_sampled` count over `n_total`.
              type: number
              format: double
            wall_s:
              description: Seconds the sampling itself took.
              type: number
              format: double
          required:
            - n_total
            - n_sampled
            - fraction
            - wall_s
      required:
        - state
        - g
        - density
        - cost
        - sampling
    ProfileEmptyOutput:
      title: Profile empty
      description: >-
        The profile had nothing to sample — a context with no sources, or none
        the manifest covers.
      type: object
      properties:
        state:
          description: How the run ended.
          type: string
        reason:
          description: Why no estimate could be made.
          type: string
      required:
        - state
        - reason
    ImportOutput:
      title: Import
      description: >-
        What an import staged. Staging only — the sources are not indexed until
        a curate runs.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        imported_items:
          description: Records pulled from the provider.
          type: integer
          format: int64
        output_files:
          description: >-
            Files written into the source tree. Higher than `imported_items`
            when archives or multi-page documents expanded.
          type: integer
          format: int64
        failed:
          description: Records that could not be ingested.
          type: integer
          format: int64
        skipped:
          description: >-
            Records passed over, e.g. an unsupported extension or a cap already
            reached.
          type: integer
          format: int64
        skipped_items:
          description: Bounded sample of the skipped records
          type: array
          items:
            $ref: '#/components/schemas/ImportManifestEntry'
        manifest_sample:
          description: Bounded sample of the records that produced output
          type: array
          items:
            $ref: '#/components/schemas/ImportManifestEntry'
        manifest_truncated:
          description: Whether either sample was cut
          type: boolean
        manifest_file:
          description: Where the full manifest was written
          type: string
        manifest_object:
          description: Object-store key of the full manifest
          type: string
      required:
        - status
        - imported_items
        - output_files
        - failed
        - skipped
        - skipped_items
        - manifest_sample
        - manifest_truncated
        - manifest_file
    StatusErrorOutput:
      title: Status-keyed failure
      description: >-
        What a groom or curate reports when it fails terminally: best-effort
        detail on a task left running so it can be resumed.
      type: object
      properties:
        status:
          description: How the run ended.
          type: string
        error:
          description: What went wrong.
          type: string
      required:
        - status
        - error
    StateFailedOutput:
      title: State-keyed failure
      description: The pack / restore terminal-failure convention.
      type: object
      properties:
        state:
          description: How the run ended.
          type: string
        error:
          description: What went wrong.
          type: string
      required:
        - state
        - error
    ErrorOutput:
      title: API-written failure
      description: >-
        What the API itself writes when a runtime reports a failure without an
        output of its own. Carries no `status` or `state` key.
      type: object
      properties:
        error:
          description: What went wrong.
          type: string
      required:
        - error
    ImportLimits:
      description: The caps the import ran under.
      type: object
      properties:
        allow_archives:
          description: Whether the run was permitted to expand archives.
          type: boolean
        allowed_extensions:
          description: File extensions the run was allowed to ingest.
          type: array
          items:
            description: One permitted file extension.
            type: string
        remaining_files:
          description: Files left under the context's file cap when the run started.
          type: integer
          format: int64
        remaining_bytes:
          description: Bytes left under the context's byte cap when the run started.
          type: integer
          format: int64
        max_file_bytes:
          description: Upper bound on one stored object.
          type: integer
          format: int64
    Manifest:
      description: >-
        The document that drives curate and search. Sparse: every field is
        optional and an omitted one falls back to its default, so absent fields
        are omitted rather than nulled. A change reaches the index on the next
        curate; rebuilding what is already indexed needs a forced one.
      type: object
      properties:
        curate:
          $ref: '#/components/schemas/CurateManifest'
        optimize:
          $ref: '#/components/schemas/OptimizeManifest'
        search:
          $ref: '#/components/schemas/SearchManifest'
    CandidateQuery:
      description: A query the optimize run tunes toward.
      type: object
      properties:
        ask:
          description: The question to tune retrieval against.
          type: string
        answer:
          description: Used as eval ground truth
          type: string
        fallback_to_chunks:
          description: >-
            Whether answering this query had to drill from artifacts down to
            chunks.
          type: boolean
        latency_ms:
          description: Latency the query showed in real traffic, as a tuning baseline.
          type: number
          format: double
    PackDetails:
      nullable: true
      description: >-
        LLM-written corpus summary, echoed from the pack's `details.json`. Null
        when enrichment was skipped or failed.
      type: object
      properties:
        description:
          description: Prose summary of what the packed corpus covers.
          type: string
        sample_queries:
          description: Example questions the packed corpus can answer.
          type: array
          items:
            description: One example question.
            type: string
      required:
        - description
        - sample_queries
    StageProgress:
      description: How far one restore phase has got.
      type: object
      properties:
        phase:
          description: Which phase is running, e.g. `stage_sources`.
          type: string
        done:
          description: Items finished in this phase.
          type: integer
          format: int64
        total:
          description: Items this phase will process.
          type: integer
          format: int64
      required:
        - phase
        - done
        - total
    ChatUsage:
      description: >-
        What a run billed on the chat seam, in tokens. Reported by the inference
        client, which carries the cache-token fields. Used by optimize and
        explore.
      type: object
      properties:
        prompt_tokens:
          description: Input tokens billed across every model.
          type: integer
          format: int64
        completion_tokens:
          description: Output tokens billed across every model.
          type: integer
          format: int64
        total_tokens:
          description: Input plus output tokens across every model.
          type: integer
          format: int64
        by_model:
          description: >-
            Keyed by the model the proxy actually dispatched to, so tier
            fallbacks are visible.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ModelUsage'
        cache_read_tokens:
          description: Input served without re-billing.
          type: integer
          format: int64
        cache_write_tokens:
          description: Prompt tokens written into cache.
          type: integer
          format: int64
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - by_model
        - cache_read_tokens
        - cache_write_tokens
    CurateUsage:
      description: >-
        Curate's token rollup: the chat-seam totals plus the embed/rerank seam
        (`embed_by_model`). It does not carry the cache-token fields.
      type: object
      properties:
        prompt_tokens:
          description: Input tokens billed on the chat seam.
          type: integer
          format: int64
        completion_tokens:
          description: Output tokens billed on the chat seam.
          type: integer
          format: int64
        total_tokens:
          description: Input plus output tokens on the chat seam.
          type: integer
          format: int64
        by_model:
          description: >-
            Chat-seam counts keyed by the model the proxy actually dispatched
            to.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ModelUsage'
        embed_by_model:
          description: >-
            Embed and rerank counts keyed by model. These bill separately from
            the chat totals above and are not included in them.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/SeamUsage'
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - by_model
        - embed_by_model
    TemplateMatch:
      description: One manifest template an explore run proposes for the corpus.
      type: object
      properties:
        template_id:
          description: Catalog entry the run proposes for this corpus.
          type: string
        rationale:
          description: Why the run thinks this template fits the corpus.
          type: string
        confidence:
          description: >-
            How sure the run is, 0–1. Low-confidence proposals are dropped
            before this point.
          type: number
          format: double
      required:
        - template_id
        - rationale
        - confidence
    ProfileTierCost:
      description: What the curate would cost at one model tier.
      type: object
      properties:
        tokens:
          description: >-
            The `point` estimate sits at G's midpoint and splits into
            input/output; `lo`/`hi` are band totals.
          type: object
          properties:
            point:
              description: Estimate at the artifact count's midpoint.
              type: integer
              format: int64
            lo:
              description: Total at the low end of the band.
              type: integer
              format: int64
            hi:
              description: Total at the high end of the band.
              type: integer
              format: int64
            input:
              description: Input share of the point estimate.
              type: integer
              format: int64
            output:
              description: Output share of the point estimate.
              type: integer
              format: int64
          required:
            - point
            - lo
            - hi
            - input
            - output
        time_s:
          description: Estimated wall-clock band for the curate, in seconds.
          type: object
          properties:
            lo:
              description: Low end of the wall-clock band.
              type: integer
              format: int64
            hi:
              description: High end of the wall-clock band.
              type: integer
              format: int64
          required:
            - lo
            - hi
      required:
        - tokens
        - time_s
    ImportManifestEntry:
      description: One ingest record — what happened to a single source the import saw.
      type: object
      properties:
        src:
          description: The record at the provider.
          type: string
        action:
          description: >-
            What happened to the record. `parsed` converted the file to text,
            `copied` took it as-is, `extracted` expanded an archive.
          x-enum:
            - parsed
            - copied
            - extracted
            - skipped
            - failed
          type: string
        out:
          description: Empty exactly when nothing was written
          type: array
          items:
            description: A path written into the source tree.
            type: string
        fmt:
          description: Format the ingester recognized.
          type: string
        reason:
          description: Why it was skipped or how it failed. Empty on success.
          type: string
        bytes:
          description: Bytes written for this record.
          type: integer
          format: int64
      required:
        - src
        - action
        - out
        - fmt
        - reason
        - bytes
    CurateManifest:
      description: >-
        What curate builds out of the sources — the chunk leg, the artifact leg,
        or both.
      type: object
      properties:
        chunks:
          $ref: '#/components/schemas/ChunksConfig'
        artifacts:
          $ref: '#/components/schemas/ArtifactsConfig'
    OptimizeManifest:
      description: >-
        The scheduled self-tuning loop: it clusters the queries that answered
        badly and tries candidate manifests against an ephemeral index until one
        reproduces the recorded answers.
      type: object
      properties:
        schedule:
          description: Cron expression the tuning loop runs on.
          default: 0 * * * *
          type: string
          maxLength: 128
        latency_threshold_ms:
          description: >-
            A query slower than this counts as a problem worth tuning for, as
            does any query that fell back from artifacts to chunks. `0` disables
            the latency test, leaving only fallback.
          default: 60000
          type: integer
          minimum: 0
          maximum: 600000
        min_group_size:
          description: >-
            How many near-duplicate problem queries must cluster together before
            the loop tunes for them. Keeps a one-off slow query from triggering
            a manifest change.
          default: 2
          type: integer
          minimum: 1
          maximum: 100
        eval_pass_rate_threshold:
          description: >-
            Fraction of eval queries a candidate manifest must answer correctly
            to be considered ready. `1` demands all of them.
          default: 1
          type: number
          format: double
          minimum: 0
          maximum: 1
        max_iterations:
          description: >-
            How many candidate manifests the loop tries before stopping with its
            best.
          default: 20
          type: integer
          minimum: 1
          maximum: 100
    SearchManifest:
      description: >-
        Standing instructions for the query runtime, pinned on the context
        rather than sent per turn.
      type: object
      properties:
        instructions:
          description: >-
            The context's default system prompt, applied to every turn in scope.
            A session's own `system_prompt` appends to it rather than replacing
            it.
          type: string
    ModelUsage:
      description: Per-model chat-seam counts; both usage roll-ups write every key.
      type: object
      properties:
        tier:
          description: Which tier resolved to this model, so a tier fallback is visible.
          type: string
        prompt_tokens:
          description: Input tokens billed to this model.
          type: integer
          format: int64
        completion_tokens:
          description: Output tokens billed to this model.
          type: integer
          format: int64
        cache_read_tokens:
          description: Input served without re-billing.
          type: integer
          format: int64
        cache_write_tokens:
          description: Prompt tokens written into cache.
          type: integer
          format: int64
        total_tokens:
          description: Input plus output tokens for this model.
          type: integer
          format: int64
      required:
        - tier
        - prompt_tokens
        - completion_tokens
        - cache_read_tokens
        - cache_write_tokens
        - total_tokens
    SeamUsage:
      description: >-
        Per-model embed/rerank-seam counts: billed per token (embed) or per
        request (rerank).
      type: object
      properties:
        kind:
          description: >-
            Which seam this row counts, and therefore which of the two count
            fields is meaningful.
          x-enum:
            - embed
            - rerank
          type: string
        tier:
          description: Which tier resolved to this model.
          type: string
        embed_tokens:
          description: 'Tokens embedded. Meaningful for `kind: embed`.'
          type: integer
          format: int64
        rerank_units:
          description: 'Rerank requests made. Meaningful for `kind: rerank`.'
          type: integer
          format: int64
      required:
        - kind
        - tier
        - embed_tokens
        - rerank_units
    ChunksConfig:
      description: >-
        The chunk leg — sources split into passages, embedded for semantic
        search and optionally indexed for keyword search.
      type: object
      properties:
        enabled:
          description: Whether curate builds the chunk leg at all.
          default: true
          type: boolean
        embedding_model:
          description: Model that embeds the chunks.
          default: multilingual-e5-large
          type: string
          maxLength: 128
        chunking:
          $ref: '#/components/schemas/ChunkingConfig'
        keyword:
          description: >-
            The lexical index built alongside the vectors, for exact-term
            matching.
          type: object
          properties:
            enabled:
              description: Whether the lexical index is built.
              default: true
              type: boolean
    ArtifactsConfig:
      description: >-
        The artifact leg: knowledge an LLM distills out of the sources, as prose
        files or database rows. Off by default.
      type: object
      properties:
        enabled:
          description: Whether curate extracts artifacts at all.
          default: false
          type: boolean
        artifact_model:
          description: >-
            Model tier that does the extraction. `standard` reads more carefully
            at a higher token cost.
          default: lite
          x-enum:
            - standard
            - lite
          type: string
        artifact_types:
          description: >-
            What kinds of artifact to extract. Nothing is extracted until at
            least one is declared.
          type: array
          items:
            $ref: '#/components/schemas/ArtifactType'
          maxItems: 32
        edge_types:
          description: >-
            Typed, directed relationships between artifact types, which turn the
            artifacts into a graph the agent can traverse.
          type: array
          items:
            $ref: '#/components/schemas/EdgeType'
          maxItems: 32
        min_doc_count:
          description: >-
            How many source documents must mention a corpus-scoped subject
            before it earns an artifact. Raise it to suppress one-off mentions.
            An artifact type may override it.
          default: 1
          type: integer
          minimum: 1
          maximum: 64
        max_tokens:
          description: Output cap for one extracted artifact, in tokens.
          default: 1500
          type: integer
          minimum: 128
          maximum: 8192
        max_doc_chars:
          description: >-
            Input cap for one extraction call, in characters. With windowing off
            this also caps how much of a source is read at all; everything
            beyond it is dropped.
          default: 60000
          type: integer
          minimum: 1000
          maximum: 2000000
        extraction_window_chars:
          description: >-
            Window size for walking a long source across several extraction
            calls, so its back half is covered rather than dropped. `0` opts out
            and reads only the head, up to `max_doc_chars`.
          default: 0
          type: integer
          minimum: 0
          maximum: 1000000
        mention_max_chars:
          description: >-
            Cap on one recorded mention — what a single document says about the
            subject — in characters.
          default: 400
          type: integer
          minimum: 100
          maximum: 4000
        max_mentions_per_artifact:
          description: >-
            How many mentions are fed into the pass that reduces them into one
            corpus-wide artifact.
          default: 40
          type: integer
          minimum: 1
          maximum: 500
        mention_context_chars:
          description: >-
            Cap on those mentions once concatenated, in characters. Applied
            after `max_mentions_per_artifact`.
          default: 8000
          type: integer
          minimum: 1000
          maximum: 100000
        max_artifacts_per_type:
          description: How many artifacts one type may produce. Omit for no cap.
          default: 10000
          type: integer
          minimum: 1
          maximum: 10000
    ChunkingConfig:
      description: How a source is cut into chunks.
      type: object
      properties:
        strategy:
          description: >-
            Which structure the splitter cuts on — markdown headings, fixed-size
            windows, HTML elements, CSV rows, or code syntax. Pick the one that
            matches the corpus.
          default: markdown_heading
          x-enum:
            - markdown_heading
            - sliding_window
            - html
            - csv
            - code
          type: string
        target_size:
          description: >-
            Chunk size the splitter aims for, in tokens. Smaller chunks retrieve
            more precisely; larger ones carry more surrounding context.
          default: 512
          type: integer
          minimum: 64
          maximum: 4096
        overlap:
          description: >-
            Tokens each chunk repeats from its predecessor, so a passage split
            across a boundary is still retrievable whole.
          default: 64
          type: integer
          minimum: 0
          maximum: 1024
        respect_sections:
          description: >-
            Never cut across a section boundary, even when that leaves a chunk
            short of `target_size`.
          default: true
          type: boolean
    ArtifactType:
      description: >-
        One kind of artifact to extract. `name` is required of a written
        manifest; a read echoes a stored document that lacks one rather than
        failing.
      type: object
      properties:
        name:
          description: >-
            What the type is called. Edge endpoints reference it, and a sqlite
            type's table is named after it.
          type: string
          maxLength: 64
        kind:
          description: >-
            What the artifact represents, which selects the extraction prompt.
            `glossary` is the exception — it reads the headings named in
            `sections` deterministically, with no LLM call.
          default: topic
          x-enum:
            - summary
            - topic
            - entity
            - event
            - doc
            - page
            - glossary
          type: string
        scope:
          description: >-
            How widely the extraction reaches. `document` extracts one artifact
            per source; `corpus` reduces mentions from across every source into
            one artifact per subject.
          default: corpus
          x-enum:
            - document
            - corpus
          type: string
        icon:
          description: Symbol to display beside artifacts of this kind.
          type: string
          maxLength: 64
        description:
          description: >-
            What this type should capture. Goes into the extraction prompt, so
            it steers the result.
          type: string
          maxLength: 512
        coverage:
          description: >-
            Topics the extraction is told to address wherever the source speaks
            to them.
          type: array
          items:
            description: One topic the extraction should address.
            type: string
            maxLength: 128
          maxItems: 32
        sections:
          description: >-
            Exact section headings a `glossary`-kind type reads verbatim.
            Ignored by every other kind.
          type: array
          items:
            description: One exact section heading to read.
            type: string
            maxLength: 128
          maxItems: 64
        min_doc_count:
          description: Overrides the manifest-level `min_doc_count` for this type.
          default: 1
          type: integer
          minimum: 1
          maximum: 64
        format:
          description: >-
            Where the artifacts of this type are written — `markdown` a prose
            file each, `sqlite` rows in the context's structured database.
          default: markdown
          x-enum:
            - markdown
            - sqlite
          type: string
        columns:
          description: >-
            Table schema for a `sqlite`-format type. Ignored for `markdown`. Two
            names that normalize to the same column collide, and the first
            declaration wins.
          type: array
          items:
            description: One column of the type's table.
            type: object
            properties:
              name:
                description: Column name.
                type: string
                maxLength: 64
              type:
                description: SQLite column affinity.
                default: TEXT
                x-enum:
                  - TEXT
                  - INTEGER
                  - REAL
                  - NUMERIC
                type: string
              description:
                description: What the column holds. Steers the extraction that fills it.
                type: string
                maxLength: 256
            required:
              - name
          maxItems: 64
        natural_key:
          description: >-
            Columns that identify a row uniquely, so re-curating a source
            upserts its rows rather than duplicating them. `sqlite`-format types
            only.
          type: array
          items:
            description: One column of the upsert key.
            type: string
            maxLength: 64
          maxItems: 16
      required:
        - name
    EdgeType:
      description: >-
        One typed, directed relationship between artifact types. `name`, `from`,
        and `to` are required of a written manifest; a read echoes a stored
        document that lacks one rather than failing.
      type: object
      properties:
        name:
          description: What the relationship is called, e.g. `mentions`.
          type: string
          maxLength: 64
        from:
          description: >-
            Source artifact-type name. May equal `to` for a self-referential
            edge.
          type: string
          maxLength: 64
        to:
          description: Target artifact-type name
          type: string
          maxLength: 64
        description:
          description: What the relationship means. Steers the extraction that finds it.
          type: string
          maxLength: 512
        attributes:
          description: Extra properties recorded on each edge, e.g. `count`.
          type: array
          items:
            description: One attribute name.
            type: string
            maxLength: 64
          maxItems: 16
      required:
        - name
        - from
        - to
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Session token from `POST /auth/login`, sent as `Authorization: Bearer
        <token>`.
    apiKey:
      type: apiKey
      in: header
      name: Api-Key
      description: Pinecone API key, accepted as an alternative to the bearer token.

````