MACP

Projections API Reference

Projections are pure state machines that track session state client-side. Each coordination mode has its own projection class.

Common Interface

All projections share:

PropertyTypeDescription
transcriptEnvelope[]All accepted envelopes applied to this projection
phasestring literal unionCurrent session phase
commitmentRecord<string, unknown> | undefinedCommitment payload, set on Commitment

All projections implement:

applyEnvelope(envelope: Envelope, protoRegistry: ProtoRegistry): void

This method:

  1. Checks the envelope's mode matches (ignores others)
  2. Appends to transcript
  3. Decodes the payload via protoRegistry.decodeKnownPayload()
  4. Updates internal state based on messageType

DecisionProjection

Phases: 'Proposal''Evaluation''Voting''Committed'

PropertyType
proposalsMap<string, DecisionProposalRecord>
evaluationsDecisionEvaluationRecord[]
objectionsDecisionObjectionRecord[]
votesMap<string, Map<string, DecisionVoteRecord>>
MethodReturnsDescription
voteTotals()Record<string, number>Positive vote counts per proposal
majorityWinner()string | undefinedProposal with most positive votes
hasBlockingObjection(proposalId)booleanHas high/critical/block severity objection

ProposalProjection

Phases: 'Proposing''Negotiating''Committed'

PropertyType
proposalsMap<string, ProposalRecord>
acceptsProposalAcceptRecord[]
rejectionsProposalRejectRecord[]
MethodReturnsDescription
activeProposals()ProposalRecord[]Proposals with status 'open'
latestProposal()ProposalRecord | undefinedMost recently submitted
isAccepted(proposalId)booleanHas any Accept for this ID
isTerminallyRejected(proposalId)booleanHas terminal Reject

TaskProjection

Phases: 'Requesting''InProgress''Completed' / 'Failed''Committed'

PropertyType
tasksMap<string, TaskRecord>
updatesTaskUpdateRecord[]
completionsTaskCompletionRecord[]
failuresTaskFailureRecord[]
MethodReturnsDescription
getTask(taskId)TaskRecord | undefinedFull task record
progressOf(taskId)numberCurrent progress (0.0 - 1.0)
isComplete(taskId)booleanTaskComplete received
isFailed(taskId)booleanTaskFail received
isRetryable(taskId)booleanFailed with retryable: true
activeTasks()TaskRecord[]Tasks in requested/accepted/in_progress

HandoffProjection

Phases: 'Offering''ContextSharing''Resolved''Committed'

PropertyType
handoffsMap<string, HandoffRecord>
MethodReturnsDescription
getHandoff(handoffId)HandoffRecord | undefinedFull handoff record
isAccepted(handoffId)booleanHandoffAccept received
isDeclined(handoffId)booleanHandoffDecline received
pendingHandoffs()HandoffRecord[]Handoffs in offered/context_sent status

QuorumProjection

Phases: 'Requesting''Voting''Committed'

PropertyType
requestsMap<string, ApprovalRequestRecord>
ballotsMap<string, Map<string, BallotRecord>>
MethodReturnsDescription
approvalCount(requestId)numberCount of approve ballots
rejectionCount(requestId)numberCount of reject ballots
abstentionCount(requestId)numberCount of abstain ballots
hasQuorum(requestId)booleanApprovals >= required threshold
threshold(requestId)numberRequired approvals for this request
remainingVotesNeeded(requestId)numbermax(0, required - approvalCount)
votedSenders(requestId)string[]Senders who have voted