6.5 KiB
Service API Boundary
Date: 2026-05-06
Decision
The first service boundary will be an optional FastAPI layer over the
programmatic contracts implemented in kontextual_engine. The service must not
define separate business behavior; it should expose the same artifact,
collection, relationship, ingestion, query, workflow, and context operations as
HTTP resources.
Implemented MVP Resource Shape
Implemented in KONT-WP-0009-T001:
GET /healthGET /readyGET /versionGET /api/v1/healthGET /api/v1/readyGET /api/v1/versionGET /openapi.json
Implemented in KONT-WP-0009-T002:
POST /api/v1/assetsGET /api/v1/assetsGET /api/v1/assets/{asset_id}POST /api/v1/assets/{asset_id}/metadataGET /api/v1/assets/{asset_id}/metadataPOST /api/v1/assets/{asset_id}/lifecyclePOST /api/v1/relationshipsGET /api/v1/relationshipsGET /api/v1/audit/eventsPOST /api/v1/policy/evaluate
Implemented in KONT-WP-0009-T003:
GET /api/v1/ingestion/capabilitiesPOST /api/v1/ingestion/jobsGET /api/v1/ingestion/jobsGET /api/v1/ingestion/jobs/{job_id}POST /api/v1/retrieval/index/refreshPOST /api/v1/retrieval/assetsPOST /api/v1/retrieval/context-entitiesPOST /api/v1/retrieval/relationshipsPOST /api/v1/retrieval/feedbackGET /api/v1/retrieval/feedbackGET /api/v1/retrieval/qualityGET /api/v1/transformations/operationsPOST /api/v1/transformations/runsGET /api/v1/transformations/runsGET /api/v1/transformations/runs/{run_id}POST /api/v1/transformations/runs/{run_id}/retryPOST /api/v1/transformations/runs/{run_id}/cancelPOST /api/v1/workflows/templatesGET /api/v1/workflows/templatesGET /api/v1/workflows/templates/{template_id}POST /api/v1/workflows/runsPOST /api/v1/workflows/runs/queueGET /api/v1/workflows/runsGET /api/v1/workflows/runs/{run_id}POST /api/v1/workflows/runs/{run_id}/resumePOST /api/v1/workflows/runs/{run_id}/retryPOST /api/v1/workflows/runs/{run_id}/cancelGET /api/v1/workflows/runs/{run_id}/reconstructionGET /api/v1/workflows/reviewsGET /api/v1/workflows/exceptionsPOST /api/v1/workflows/runs/{run_id}/reviews/{review_id}/decision
Implemented in KONT-WP-0009-T004:
GET /api/v1/context- Actor headers:
X-Actor-Id,X-Actor-Type,X-Actor-Display-Name,X-Actor-External-Ref,X-Actor-Groups. - Delegation headers:
X-Delegated-Actor-Id,X-Delegated-Actor-Type,X-Delegated-Actor-Display-Name,X-Delegated-Actor-External-Ref,X-Delegated-Actor-Groups. - Agent headers:
X-Agent-Id,X-Agent-Name,X-Agent-Run-Id,X-Agent-Tool. - Scope headers:
X-Request-ScopeandX-Policy-Scopeas JSON objects. - Redacted HTTP authorization error payloads.
Implemented in KONT-WP-0009-T005:
GET /api/v1/agents/operationsGET /api/v1/agents/operations/{operation_id}POST /api/v1/agents/operations/{operation_id}- Catalog entries declare input/output shape notes, permissions, audit operation, failure modes, and dry-run support.
- Execution is limited to documented operation IDs and emits separate
agent.operation.*audit events before dispatching through existing service contracts.
Implemented in KONT-WP-0009-T006:
GET /api/v1/context-packages/schemaPOST /api/v1/context-packages- Context packages are assembled from governed retrieval results.
- Payloads carry source refs, snippets, metadata, relationships, policy constraints, opaque external memory refs, and audit/policy references.
- The
markitectformat emits a Markitect-compatible envelope while keeping markdown rendering and selector semantics delegated tomarkitect-tool.
Implemented in KONT-WP-0009-T007:
- Agent operation policies can return
require_reviewand receive structuredreview_requiredenvelopes with review obligations. - Agent operation policies can return
dry_run_onlyand receivedry_run_requiredenvelopes unless the request is already a dry run. - Review and dry-run outcomes are audited with explicit
review_requiredanddry_runaudit outcomes. - Partial-failure job envelopes are covered by contract tests.
Implemented in KONT-WP-0010:
GET /api/v1/operations/metricsGET /api/v1/operations/jobsGET /api/v1/operations/eventsGET /api/v1/operations/recovery/actionsPOST /api/v1/operations/recovery/{action}POST /api/v1/exportsPOST /api/v1/exports/validatePOST /api/v1/governance/reportGET /api/v1/extensions/catalogPOST /api/v1/extensions/eventsPOST /api/v1/quality/signalsGET /api/v1/quality/costGET /api/v1/performance/smokeGET /api/v1/compliance/mvp- Operator/readiness endpoints remain policy checked and audit backed.
The unversioned health/readiness/version endpoints are operational probes. The
versioned /api/v1/* endpoints establish the MVP API namespace. Future
domain-resource endpoints should live under /api/v1.
The service dependency is optional. Importing kontextual_engine and
kontextual_engine.api does not require FastAPI; calling create_app() does.
Install the service extra to run the HTTP adapter:
python3 -m pip install -e '.[service]'
Planned Resource Shape
Remaining planned endpoint groups:
POST /collections,GET /collections,GET /collections/{id}POST /artifacts,GET /artifacts/{id},GET /artifactsPOST /context/artifact/{id}
For the governed asset registry architecture, these planned groups should be translated to assets, metadata, context packages, and bounded agent operation resources.
MVP API Versioning Policy
/api/v1is the first stable namespace for implemented service resources.- Backward-incompatible changes require a new namespace such as
/api/v2. - Additive response fields are allowed inside a version.
- Structured diagnostics and error codes are part of the contract and should remain stable inside a version.
- Unversioned operational probes may remain as aliases for the active API generation, but domain-resource endpoints must be versioned.
Rules
- The Python API is canonical until contracts stabilize.
- HTTP handlers must translate request/response envelopes only.
- Markdown parsing, document transforms, selectors, contracts, and local
indexes must remain adapter calls to
markitect-tool. - Provider calls must remain adapter calls to
llm-connect. - Structured diagnostics and errors must be preserved in responses.
Deferred
No MVP service API task remains deferred in this workplan.
- Streaming run execution.
- Provider-backed assisted steps.