Skip to content

[ADR-016] Request Execution Modes and Presentation Envelope #323

@ohdearquant

Description

@ohdearquant

Summary

Implement parsed request execution modes, structured runtime errors, MCP chain/batch dispatch, bulk-operation dispatch safety, and presentation controls/envelopes for request responses.

Source ADRs

  • F086 ADR-016 (CRIT): ParsedRequest contains only ops: Vec and has no mode (from audit-platform/e2/ADR-016.md)
  • F087 ADR-016 (CRIT): Pipe chains are documented as planned/deferred (from audit-platform/e2/ADR-016.md)
  • F088 ADR-016 (CRIT): run_parsed maps every parsed op into a future and executes all requests with join_all, so every multi-op request is treated as an independent parallel batch. (from audit-platform/e2/ADR-016.md)
  • F089 ADR-016 (MAJ): Runtime errors expose generic NotFound(String) and Ambiguous(String) variants (from audit-platform/e2/ADR-016.md)
  • F206 ADR-038 (CRIT): run_parsed maps every parsed op directly to a future and executes join_all (from audit-rest/r3/ADR-038.md)
  • F237 ADR-045 (MAJ): Runtime exports modules for curation, fusion, operations, pack, portability, registry, retrieval, and runtime, but no presentation module. (from audit-rest/r5/ADR-045.md)
  • F238 ADR-045 (MAJ): RequestParams contains only ops. server.rs parses only p.ops and passes parsed operations to run_parsed. There is no presentation, presentation_per_op, or include_full_id envelope... (from audit-rest/r5/ADR-045.md)
  • F240 ADR-045 (MAJ): VerbRegistry::dispatch returns the pack handler's serde_json::Value directly. (from audit-rest/r5/ADR-045.md)

Files affected

  • crates/khive-request/src/lib.rs (738 sampled LOC)
  • crates/khive-mcp/src/server.rs (404 sampled LOC)
  • crates/khive-runtime/src/error.rs (125 sampled LOC)
  • crates/khive-runtime/src/pack.rs (2677 sampled LOC)
  • crates/khive-runtime/src/lib.rs (55 sampled LOC)
  • crates/khive-mcp/src/tools/request.rs (22 sampled LOC)
  • crates/khive-runtime/src/presentation.rs (new/planned path)
  • crates/khive-runtime/src/operations.rs (3728 sampled LOC)
  • crates/khive-pack-kg/src/handlers.rs (1216 sampled LOC)

Acceptance criteria

  • All source findings listed above are addressed exactly once in this cluster.
  • Public types, handlers, schema, and docs touched by the affected files agree on the ADR contract.
  • Regression tests cover happy path and edge cases for the changed public APIs or schema behavior.
  • cargo test -p khive-request -p khive-mcp -p khive-runtime passes.
  • cargo clippy --workspace -- -D warnings passes.
  • make ci passes.

Dependencies

  • Depends on: #[ADR-001] Entity Kind and Type Contract
  • Depends on: #[ADR-002] Edge Ontology, Lifecycle, and Bulk Link Semantics
  • Depends on: #[ADR-004] Note Kind, Storage, and Curation Operations
  • Depends on: #[ADR-005] Storage Capabilities, Sparse Store, and Vector Contract
  • Depends on: #[ADR-004] Event Observable and Provenance Model
  • Depends on: #[ADR-007] Namespace Token and Runtime API Migration
  • Depends on: #[ADR-003] Runtime Backend and Substrate Coordinator
  • Depends on: #[ADR-008] Query Layer Contract
  • Depends on: #[ADR-004] HandlerDef Pack Contract
  • Depends on: #[ADR-017] Pack Verb Registry, Wire Names, and Introspection
  • Blocks: #[ADR-023] Dynamic Pack Loading, Template, and Pack Binary Inclusion
  • Blocks: #[ADR-004] GTD Pack Schema Plan and Lifecycle Audit
  • Blocks: #[ADR-025] Event-Sourced Proposals
  • Blocks: #[ADR-035] Import, Export, Remote Resolver, and Sync

LOC estimate

~340 lines added/90 removed; 8 existing affected file(s) sampled at 8965 current LOC via wc -l, plus 1 new/planned path(s).

Risk notes

  • Same-file dependencies must merge first; dependency list includes the exact overlapping paths.
  • 1 affected path(s) are new/planned and were not present in rg --files --hidden; create them in the owning PR rather than in independent parallel work.
  • Contains CRIT findings; do not defer without owner approval.

Auto-generated by ADR alignment triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    adr-alignmentADR v1 series alignment workadvancedAdvanced layer (ADR-031..046)platformPlatform layer (ADR-016..030)

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions