System Design Atlas

Knowledge assistant with source references

04 / 10Worked example

Interfaces

What information does an answer need besides the text?

This API proposal belongs to the worked example. The server determines permissions. The client cannot approve documents or inject unchecked source IDs as valid context.

Starting point Q-17 must enforce permissions on the server and may end with evidence, a knowledge gap or a technical failure.

Assumptions for the example case

Example design: one operator's internal knowledge, a bounded document collection and existing authentication. Numbers and targets are assumptions. The assistant reads knowledge; tool actions and open-web research are outside scope.

Answer A-17 with status and references

Synchronous response contract for Q-17 with separate results

POST /answersQuestion, field of knowledge, requestKey; identity from session

Server-side processing

Final replyAnswer ID, status, text and sources or separate technical errors.

Idempotency contract: Within the agreed retry window, the same requestKey for the same user and complete request starts no second generation. Changed parameters are rejected; permissions are checked before each output. Define the retry window together with protected result retention.

answered

Documented reply

A-17 contains text and references to selected P-17 DV-17.
  • Server-side contract
  • Answer and evidence trace
  • Domain feedback or error

The client submits the question. The server determines roles, permissions and evidence; the synchronous response distinguishes domain statuses, technical errors and withheld output.

The API contract treats answer text, references and domain status as one result.

The key contracts

  1. POST/answers

    Request an answer supported by evidence

    Input
    Question, approved knowledge area and requestKey; user identity from the session.
    Result
    Answer ID, status `answered` / `insufficient_evidence` / `conflicting_sources`, text and sources with original, document version, pipeline version and position anchor. Technical errors and withheld outputs are separate from the domain answer status.
    Retry behaviour
    The requestKey is bound to the user and complete request. Within the agreed retry window, an identical request starts no second generation; the same key with different parameters is rejected. Permissions are rechecked before replaying output. Define the retry window together with protected result retention.
  2. GET/sources/{documentId}/versions/{version}

    Open the reference used

    Input
    Document and version reference from the response; currently authorized user.
    Result
    Accessible original or concrete passage with position anchor; no protected content if access is withdrawn. The reference remains traceable back to its source status at that time.
    Retry behaviour
    Reading; each query checks the current rights and availability.
  3. POST/document-imports

    Prepare a document version

    Input
    Authorized knowledge management, source reference and expected version; content only from permitted sources.
    Result
    202 with import ID and processing status. An old active version remains usable until full release.
    Retry behaviour
    The same source version and pipeline version create no duplicate index data.
  4. POST/answer-feedback

    Evaluate answer quality in its domain

    Input
    Authorised person, answer ID and error category; optional bounded comment.
    Result
    Stored review feedback referencing the version used.
    Retry behaviour
    Stable feedback key prevents accidental duplicates.

Mistakes must be distinguished from knowledge gaps

No supporting documents
`insufficient_evidence` is a valid domain result identifying a knowledge gap. `conflicting_sources` indicates contradictory approved sources. Model failure is a technical error; output withheld after permission revocation contains no unverified answer fragments.
Time limit and output
The initial design withholds the entire draft until source and permission checks pass. Unchecked streaming could expose blocked claims; revocation causes the whole draft to be withheld.

Try it yourself

Sketch the request, retrieval, structured response and insufficient_evidence result. Mark data the client cannot determine.

A hint for your attempt

References need a document, version and passage. Status distinguishes a domain knowledge gap from a technical error.

Compare with a possible solution
Request and search
The person sends POST /answers with the question and requestKey. The API derives identity and current permissions from the session, searches the permitted collection and selects at most six supporting passages. The client cannot declare its role or external sources authorised. A manipulated permission field must have no effect.
Response
A-17 contains text, references with original, version, pipeline and position anchor, and `answered`; these references and the model context are determined by the backend alone. Test: Every statement issued is checked against this very passage; an unknown or outdated reference leads to the withheld output.
Knowledge gap
`insufficient_evidence` provides no unjustifiably confident answer and is technically processed successfully. Test: A question with no expected evidence receives this status; model failure receives a separate technical error response.

Apply to your project

What does your system's contract return when the correct domain result is empty or uncertain?

The references in the contract determine the data and version model in step 5.