Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

Canonical Event Contract

StatusUpdatedCovered Files
🟢 Stable2026-02-27src/shared/events/*, src/core/eventBus.ts

Purpose

This document defines the canonical cross-feature status and event contract used by Grants, Projects, Compliance, Billing, AI Agents, and Extensions.

Canonical Status Primitives

The canonical status vocabulary is intentionally fixed and minimal:
  • pending
  • progress
  • blocked
  • completed
  • failed
Transition rules are enforced by canTransitionCanonicalStatus() in src/shared/events/canonicalStatus.ts.

Canonical Envelope

All canonical events must satisfy canonicalEventEnvelopeSchema in src/shared/events/canonicalEventSchema.ts:
{
  eventId: string;
  eventType: string;
  schemaVersion: string;
  organizationId: string;
  domain: 'grant_lifecycle' | 'expense_audit' | 'agent_run' | 'billing' | 'compliance' | 'project' | 'extension';
  entityType: 'grant' | 'expense' | 'agent_run' | 'billing' | 'compliance' | 'project' | 'extension';
  entityId: string;
  status: 'pending' | 'progress' | 'blocked' | 'completed' | 'failed';
  reason?: string;
  occurredAt: ISO8601;
  sourceEventType: SystemEventType;
  source?: string;
  correlationId?: string;
  payload: Record<string, unknown>;
}
Metadata policy:
  • source is required from producer helpers (emitCanonicalSystemEvent).
  • correlationId is required for multi-step workflows and retries.
  • version in system-event metadata is set to canonical contract version (1.0.0).

Canonical Taxonomy (Epic 1 Scope)

grant.lifecycle.*

  • grant.lifecycle.added_to_pipeline
  • grant.lifecycle.stage_changed
  • grant.lifecycle.application_submitted
  • grant.lifecycle.won
  • grant.lifecycle.lost
  • grant.lifecycle.report_due
  • grant.lifecycle.report_submitted
  • grant.lifecycle.disbursement_received

expense.audit.*

  • expense.audit.submitted
  • expense.audit.approved
  • expense.audit.rejected

agent.run.*

  • agent.run.started
  • agent.run.step_completed
  • agent.run.escalation_required
  • agent.run.escalation_resolved
  • agent.run.completed
  • agent.run.failed
  • agent.run.cancelled

Versioning and Compatibility Policy

Canonical version constants are maintained in src/shared/events/canonicalEventVersion.ts:
  • Current: 1.0.0
  • Minimum supported: 1.0.0
Compatibility rules:
  1. Accept only the current major (1.x.x).
  2. Reject versions lower than minimum supported.
  3. Reject future major versions (2.x.x).
Deprecation policy:
  1. Breaking changes require a major version bump and migration plan.
  2. Minor additions are backward-compatible and can be introduced in 1.x.
  3. Contract tests must pass for all supported versions before release.

Governance

Contract change checklist:
  1. Update canonicalEventMap.ts and canonicalEventSchema.ts.
  2. Add/adjust tests in canonicalEventSchema.test.ts, canonicalEventVersion.test.ts, and integration flow tests.
  3. Update this document and event-catalog.md if taxonomy scope changes.
  4. Announce migration guidance in release notes for any compatibility-impacting change.

Sign-off Record (Epic 1)

RoleOwnerStatus
Platform ArchitectureTBDPending
Grants Domain LeadTBDPending
Compliance Domain LeadTBDPending
Billing Domain LeadTBDPending
AI/Agents LeadTBDPending
For cross-epic rollout state, see docs/engineering/architecture/canonical-rollout-status.md.