feat(contracts): @insignia/iios-contracts — scope, enums, platform ports, CloudEvents, errors

Verbatim IiosPlatformPorts from the bottom-up atlas; orgId/appId required scope
(KG-02); PolicyDeniedError for fail-closed. Vitest as workspace test runner.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-30 20:59:34 +05:30
parent c00d038df2
commit fbea291609
12 changed files with 1248 additions and 3 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* CloudEvents envelope + the IIOS event catalog (Data Model §05, Ref Arch §09).
*
* Every durable state change writes the business row AND an outbox event in the
* same transaction. The `insignia` block carries correlation/causation/scope and
* the idempotency key; payloads reference content rather than embedding raw PII.
*/
export type DataClass = 'internal' | 'restricted' | 'confidential' | 'regulated';
export interface CloudEvent<T = unknown> {
specversion: '1.0';
id: string;
type: string;
source: string;
subject?: string;
time: string;
datacontenttype?: 'application/json';
traceparent?: string;
insignia: {
correlationId?: string;
causationId?: string;
scopeSnapshotId?: string;
policyDecisionId?: string;
consentReceiptRef?: string;
contextBundleId?: string;
idempotencyKey: string;
dataClass?: DataClass;
};
data: T;
}
/** Canonical event names (the subset relevant up to P4; others added per phase). */
export const IIOS_EVENTS = {
rawReceived: 'com.insignia.iios.raw.received.v1',
interactionNormalized: 'com.insignia.iios.interaction.normalized.v1',
messagePersisted: 'com.insignia.iios.message.persisted.v1',
inboxItemCreated: 'com.insignia.iios.inbox.item.created.v1',
ticketCreated: 'com.insignia.iios.support.ticket.created.v1',
notificationQueued: 'com.insignia.iios.notification.queued.v1',
deliveryAttempted: 'com.insignia.iios.delivery.attempted.v1',
} as const;
export type IiosEventType = (typeof IIOS_EVENTS)[keyof typeof IIOS_EVENTS];