Skip to content

MAP Commands -- Phase 2.1 -- Define initial command set (v0) #404

@evomimic

Description

@evomimic

MAP Commands — Phase 2.1 — Establish Command Contract and Runtime Binding Seam (v0)


1. Summary (Required)

What is the enhancement?

Implement the initial MAP Commands contract defined in the
MAP Commands Specification.

This phase establishes the code scaffolding necessary to support the specification’s architecture:

  • Canonical IPC envelope types (MapIpcRequest, MapIpcResponse)
  • Structural command model (MapCommandWire)
  • Post-bind domain command model (MapCommand)
  • The Runtime binding seam (Wire → Domain)
  • A minimal dispatcher path enabling end-to-end execution of at least one command

The goal of this phase is to make the command architecture compile, bind, and execute through the Runtime boundary, without yet implementing full lifecycle enforcement or full command coverage.

The MAP Commands Specification is the authoritative definition of the command architecture.
This issue focuses strictly on implementing that specification.


2. Problem Statement (Required)

Why is this needed?

Current command plumbing still reflects legacy assumptions:

  • String-based command authority (name: String)
  • Mixed or implicit command scope
  • Binding and lifecycle policy distributed across ingress and receptor paths
  • Inconsistent distinction between MAP domain commands and operational commands

Before centralizing execution inside Runtime, we must stabilize the command contract so the architecture becomes enforceable:

  • IPC ingress accepts wire-layer types only
  • Domain execution operates on domain command types only
  • Command scope is explicit and structural
  • Binding occurs exclusively inside Runtime::dispatch
  • Lifecycle policy can be centralized in Runtime in Phase 2.2

This phase introduces the structural command model and binding seam required for that centralization.


3. Dependencies (Required)

Reference documentation:

These documents define the normative command model and command inventory.

Prerequisites already available:

  • Transaction-bound reference model and lifecycle primitives in core
  • Existing *Wire.bind(context) binding patterns
  • Existing transaction context management

Must land before:

  • Phase 2.2 Runtime dispatcher centralization
  • Phase 3 single-domain-ingress cutover
  • SDK contract stabilization for MAP commands

4. Implementation Tasks (Required)

4.1 Implement IPC Envelope Types

Define the canonical IPC request/response envelopes defined by the specification:

pub struct MapIpcRequest {
    pub request_id: RequestId,
    pub command: MapCommandWire,
}

pub struct MapIpcResponse {
    pub request_id: RequestId,
    pub result: Result<MapResultWire, HolonErrorWire>,
}

Rules:

  • These types exist only at the IPC boundary
  • They must be serializable
  • They must not appear below the Runtime binding seam

4.2 Implement Structural Command Model

Implement the structural command hierarchy:

pub enum MapCommandWire {
    Space(SpaceCommandWire),
    Transaction(TransactionCommandWire),
    Holon(HolonCommandWire),
}

This replaces legacy string-based command routing.

Command authority must derive from the structural variant, not from strings.


4.3 Implement Domain Command Types

Define the post-binding domain command model:

pub enum MapCommand {
    Space(SpaceCommand),
    Transaction(TransactionCommand),
    Holon(HolonCommand),
}

Rules:

  • Domain command types must not reference any *Wire types
  • Domain types must not require serialization
  • Transaction identifiers must be replaced by bound runtime objects (e.g., TransactionContextHandle)

4.4 Implement Runtime Binding Seam

Create the Runtime binding seam that converts wire commands into domain commands.

Binding must occur only inside Runtime.

Responsibilities include:

  • Binding MapCommandWire → MapCommand
  • Resolving transaction context
  • Resolving holon references
  • Returning deterministic errors for binding failures

4.5 Implement IPC Entrypoint

Implement the single IPC ingress defined by the specification:

#[tauri::command]
async fn dispatch_map_command(
    state: State<'_, Runtime>,
    request: MapIpcRequest,
) -> Result<MapIpcResponse, HolonErrorWire>

This function must:

  • Accept wire-layer types only
  • Delegate immediately to Runtime::dispatch
  • Perform no binding
  • Perform no lifecycle enforcement
  • Perform no descriptor evaluation

4.6 Provide Minimal Dispatcher Implementation

Provide a minimal Runtime dispatcher capable of executing one command end-to-end.

Example structure:

Runtime::dispatch
  → bind
  → dispatch_command
  → dispatch_space / dispatch_transaction / dispatch_holon

All other commands may temporarily return NotImplemented.

The goal is to verify:

  • wire/domain separation compiles
  • binding seam functions correctly
  • dispatcher path works end-to-end

Full dispatcher policy enforcement is deferred to Phase 2.2.


5. Scope and Impact (Required)

This issue impacts:

  • MAP IPC command contract types
  • TypeScript client command models
  • Runtime command binding structure
  • Command routing architecture

Not in scope for this phase:

  • Full Runtime lifecycle policy enforcement
  • Full command coverage
  • Receptor removal or plumbing changes
  • Descriptor enforcement implementation
  • Tauri ingress cutover

Those are addressed in later phases.


6. Testing Considerations (Required)

Testing should verify the contract architecture works correctly:

  • Serde roundtrip tests for IPC wire types
  • Compile-time validation that domain types contain no *Wire references
  • Basic integration test exercising the end-to-end dispatch path
  • Validation of structural command routing

Legacy ingress paths may continue to function in parallel.


7. Definition of Done (Required)

This phase is complete when:

  • MapIpcRequest and MapIpcResponse are implemented
  • MapCommandWire structural command model is implemented
  • Domain command model (MapCommand) compiles without wire dependencies
  • Runtime binding seam (Wire → Domain) exists
  • dispatch_map_command IPC entrypoint delegates to Runtime
  • At least one command executes end-to-end through the new path
  • Basic contract tests pass

This phase establishes the structural command contract and Runtime binding seam required for Phase 2.2 to centralize dispatcher policy and lifecycle enforcement inside Runtime.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions