/** * Dispute Attestation Types and Validators (v0.9.27+) * * Provides formal mechanism for contesting PEAC receipts, attributions, * and identity claims with lifecycle state management. * * @see docs/specs/DISPUTE.md for normative specification */ import { z } from 'zod'; /** * Dispute limits for DoS protection and validation. * * These are implementation safety limits, not protocol constraints. */ export declare const DISPUTE_LIMITS: { /** Maximum grounds per dispute */ readonly maxGrounds: 10; /** Maximum supporting receipts */ readonly maxSupportingReceipts: 50; /** Maximum supporting attributions */ readonly maxSupportingAttributions: 50; /** Maximum supporting documents */ readonly maxSupportingDocuments: 20; /** Maximum description length in chars */ readonly maxDescriptionLength: 4000; /** Maximum details length per ground in chars */ readonly maxGroundDetailsLength: 1000; /** Maximum rationale length in chars */ readonly maxRationaleLength: 4000; /** Maximum remediation details length in chars */ readonly maxRemediationDetailsLength: 4000; /** Minimum description for 'other' dispute type */ readonly minOtherDescriptionLength: 50; }; /** * Dispute ID schema using ULID format. * * @example "01ARZ3NDEKTSV4RRFFQ69G5FAV" */ export declare const DisputeIdSchema: z.ZodString; export type DisputeId = z.infer; /** * Type of dispute being filed. * * - 'unauthorized_access': Content accessed without valid receipt * - 'attribution_missing': Used content without attribution * - 'attribution_incorrect': Attribution exists but is wrong * - 'receipt_invalid': Receipt was fraudulently issued * - 'identity_spoofed': Agent identity was impersonated * - 'purpose_mismatch': Declared purpose doesn't match actual use * - 'policy_violation': Terms/policy violated despite receipt * - 'other': Catch-all (requires description >= 50 chars) */ export declare const DisputeTypeSchema: z.ZodEnum<{ unauthorized_access: "unauthorized_access"; attribution_missing: "attribution_missing"; attribution_incorrect: "attribution_incorrect"; receipt_invalid: "receipt_invalid"; identity_spoofed: "identity_spoofed"; purpose_mismatch: "purpose_mismatch"; policy_violation: "policy_violation"; other: "other"; }>; export type DisputeType = z.infer; /** * Array of valid dispute types for runtime checks. */ export declare const DISPUTE_TYPES: readonly ["unauthorized_access", "attribution_missing", "attribution_incorrect", "receipt_invalid", "identity_spoofed", "purpose_mismatch", "policy_violation", "other"]; /** * Type of entity being disputed. * * - 'receipt': A PEAC receipt * - 'attribution': An attribution attestation * - 'identity': An agent identity attestation * - 'policy': A policy decision or enforcement */ export declare const DisputeTargetTypeSchema: z.ZodEnum<{ receipt: "receipt"; attribution: "attribution"; identity: "identity"; policy: "policy"; }>; export type DisputeTargetType = z.infer; /** * Array of valid target types for runtime checks. */ export declare const DISPUTE_TARGET_TYPES: readonly ["receipt", "attribution", "identity", "policy"]; /** * Specific grounds for the dispute. * * Evidence-based: * - 'missing_receipt': No receipt exists for access * - 'expired_receipt': Receipt was expired at time of use * - 'forged_receipt': Receipt signature invalid or tampered * - 'receipt_not_applicable': Receipt doesn't cover the resource * * Attribution-based: * - 'content_not_used': Content was not actually used * - 'source_misidentified': Wrong source attributed * - 'usage_type_wrong': RAG claimed but was training, etc. * - 'weight_inaccurate': Attribution weight is incorrect * * Identity-based: * - 'agent_impersonation': Agent ID was spoofed * - 'key_compromise': Signing key was compromised * - 'delegation_invalid': Delegation chain is broken * * Policy-based: * - 'purpose_exceeded': Used beyond declared purpose * - 'terms_violated': Specific terms were violated * - 'rate_limit_exceeded': Exceeded rate limits */ export declare const DisputeGroundsCodeSchema: z.ZodEnum<{ missing_receipt: "missing_receipt"; expired_receipt: "expired_receipt"; forged_receipt: "forged_receipt"; receipt_not_applicable: "receipt_not_applicable"; content_not_used: "content_not_used"; source_misidentified: "source_misidentified"; usage_type_wrong: "usage_type_wrong"; weight_inaccurate: "weight_inaccurate"; agent_impersonation: "agent_impersonation"; key_compromise: "key_compromise"; delegation_invalid: "delegation_invalid"; purpose_exceeded: "purpose_exceeded"; terms_violated: "terms_violated"; rate_limit_exceeded: "rate_limit_exceeded"; }>; export type DisputeGroundsCode = z.infer; /** * Array of valid grounds codes for runtime checks. */ export declare const DISPUTE_GROUNDS_CODES: readonly ["missing_receipt", "expired_receipt", "forged_receipt", "receipt_not_applicable", "content_not_used", "source_misidentified", "usage_type_wrong", "weight_inaccurate", "agent_impersonation", "key_compromise", "delegation_invalid", "purpose_exceeded", "terms_violated", "rate_limit_exceeded"]; /** * Individual dispute ground with supporting evidence reference. */ export declare const DisputeGroundsSchema: z.ZodObject<{ code: z.ZodEnum<{ missing_receipt: "missing_receipt"; expired_receipt: "expired_receipt"; forged_receipt: "forged_receipt"; receipt_not_applicable: "receipt_not_applicable"; content_not_used: "content_not_used"; source_misidentified: "source_misidentified"; usage_type_wrong: "usage_type_wrong"; weight_inaccurate: "weight_inaccurate"; agent_impersonation: "agent_impersonation"; key_compromise: "key_compromise"; delegation_invalid: "delegation_invalid"; purpose_exceeded: "purpose_exceeded"; terms_violated: "terms_violated"; rate_limit_exceeded: "rate_limit_exceeded"; }>; evidence_ref: z.ZodOptional; details: z.ZodOptional; }, z.core.$strict>; export type DisputeGrounds = z.infer; /** * Dispute lifecycle states. * * State flow: * ``` * FILED -> ACKNOWLEDGED -> UNDER_REVIEW -> RESOLVED * | | | * +-> REJECTED +-> ESCALATED +-> APPEALED * | * +-> FINAL * ``` * * Terminal states (REQUIRE resolution): resolved, rejected, final * Non-terminal states: filed, acknowledged, under_review, escalated, appealed */ export declare const DisputeStateSchema: z.ZodEnum<{ filed: "filed"; acknowledged: "acknowledged"; under_review: "under_review"; escalated: "escalated"; resolved: "resolved"; rejected: "rejected"; appealed: "appealed"; final: "final"; }>; export type DisputeState = z.infer; /** * Array of valid dispute states for runtime checks. */ export declare const DISPUTE_STATES: readonly ["filed", "acknowledged", "under_review", "escalated", "resolved", "rejected", "appealed", "final"]; /** * Terminal states that REQUIRE a resolution field. */ export declare const TERMINAL_STATES: readonly DisputeState[]; /** * Canonical state transition table for dispute lifecycle. * * This is the SINGLE SOURCE OF TRUTH for valid transitions. * Do not duplicate elsewhere - reference this constant. */ export declare const DISPUTE_TRANSITIONS: Record; /** * Check if a state transition is valid. * * @param current - Current dispute state * @param next - Proposed next state * @returns True if the transition is valid */ export declare function canTransitionTo(current: DisputeState, next: DisputeState): boolean; /** * Check if a state is terminal (requires resolution). * * @param state - Dispute state to check * @returns True if the state is terminal */ export declare function isTerminalState(state: DisputeState): boolean; /** * Get valid next states from current state. * * @param current - Current dispute state * @returns Array of valid next states */ export declare function getValidTransitions(current: DisputeState): readonly DisputeState[]; /** * Outcome of a resolved dispute. * * - 'upheld': Dispute was valid, in favor of filer * - 'dismissed': Dispute invalid or without merit * - 'partially_upheld': Some grounds upheld, others dismissed * - 'settled': Parties reached agreement */ export declare const DisputeOutcomeSchema: z.ZodEnum<{ upheld: "upheld"; dismissed: "dismissed"; partially_upheld: "partially_upheld"; settled: "settled"; }>; export type DisputeOutcome = z.infer; /** * Array of valid outcomes for runtime checks. */ export declare const DISPUTE_OUTCOMES: readonly ["upheld", "dismissed", "partially_upheld", "settled"]; /** * Type of remediation action taken. * * - 'attribution_corrected': Attribution was fixed * - 'receipt_revoked': Receipt was revoked * - 'access_restored': Access was restored * - 'compensation': Financial compensation provided * - 'policy_updated': Policy was updated * - 'no_action': No action required * - 'other': Other remediation */ export declare const RemediationTypeSchema: z.ZodEnum<{ other: "other"; attribution_corrected: "attribution_corrected"; receipt_revoked: "receipt_revoked"; access_restored: "access_restored"; compensation: "compensation"; policy_updated: "policy_updated"; no_action: "no_action"; }>; export type RemediationType = z.infer; /** * Array of valid remediation types for runtime checks. */ export declare const REMEDIATION_TYPES: readonly ["attribution_corrected", "receipt_revoked", "access_restored", "compensation", "policy_updated", "no_action", "other"]; /** * Remediation action taken to address the dispute. */ export declare const RemediationSchema: z.ZodObject<{ type: z.ZodEnum<{ other: "other"; attribution_corrected: "attribution_corrected"; receipt_revoked: "receipt_revoked"; access_restored: "access_restored"; compensation: "compensation"; policy_updated: "policy_updated"; no_action: "no_action"; }>; details: z.ZodString; deadline: z.ZodOptional; }, z.core.$strict>; export type Remediation = z.infer; /** * Resolution of a dispute. * * Required for terminal states (resolved, rejected, final). */ export declare const DisputeResolutionSchema: z.ZodObject<{ outcome: z.ZodEnum<{ upheld: "upheld"; dismissed: "dismissed"; partially_upheld: "partially_upheld"; settled: "settled"; }>; decided_at: z.ZodString; decided_by: z.ZodString; rationale: z.ZodString; remediation: z.ZodOptional; details: z.ZodString; deadline: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>; export type DisputeResolution = z.infer; /** * Contact method for dispute resolution. * * - 'email': Email address * - 'url': URL (webhook, contact form) * - 'did': Decentralized identifier */ export declare const ContactMethodSchema: z.ZodEnum<{ did: "did"; email: "email"; url: "url"; }>; export type ContactMethod = z.infer; /** * Contact information for dispute communication. * * Validated based on method type. */ export declare const DisputeContactSchema: z.ZodObject<{ method: z.ZodEnum<{ did: "did"; email: "email"; url: "url"; }>; value: z.ZodString; }, z.core.$strict>; export type DisputeContact = z.infer; /** * Reference to an external document supporting the dispute. */ export declare const DocumentRefSchema: z.ZodObject<{ uri: z.ZodString; content_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; description: z.ZodOptional; }, z.core.$strict>; export type DocumentRef = z.infer; /** * Dispute evidence with cross-field invariants enforced via superRefine. * * Invariants: * 1. Terminal states (resolved, rejected, final) REQUIRE resolution * 2. Resolution is ONLY valid for terminal states * 3. Dispute type 'other' requires description >= 50 characters */ export declare const DisputeEvidenceSchema: z.ZodObject<{ dispute_type: z.ZodEnum<{ unauthorized_access: "unauthorized_access"; attribution_missing: "attribution_missing"; attribution_incorrect: "attribution_incorrect"; receipt_invalid: "receipt_invalid"; identity_spoofed: "identity_spoofed"; purpose_mismatch: "purpose_mismatch"; policy_violation: "policy_violation"; other: "other"; }>; target_ref: z.ZodString; target_type: z.ZodEnum<{ receipt: "receipt"; attribution: "attribution"; identity: "identity"; policy: "policy"; }>; grounds: z.ZodArray; evidence_ref: z.ZodOptional; details: z.ZodOptional; }, z.core.$strict>>; description: z.ZodString; supporting_receipts: z.ZodOptional>; supporting_attributions: z.ZodOptional>; supporting_documents: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; description: z.ZodOptional; }, z.core.$strict>>>; contact: z.ZodOptional; value: z.ZodString; }, z.core.$strict>>; state: z.ZodEnum<{ filed: "filed"; acknowledged: "acknowledged"; under_review: "under_review"; escalated: "escalated"; resolved: "resolved"; rejected: "rejected"; appealed: "appealed"; final: "final"; }>; state_changed_at: z.ZodOptional; state_reason: z.ZodOptional; resolution: z.ZodOptional; decided_at: z.ZodString; decided_by: z.ZodString; rationale: z.ZodString; remediation: z.ZodOptional; details: z.ZodString; deadline: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>>; window_hint_days: z.ZodOptional; }, z.core.$strict>; export type DisputeEvidence = z.infer; /** * Attestation type literal for disputes. */ export declare const DISPUTE_TYPE: "peac/dispute"; /** * DisputeAttestation - formal mechanism for contesting PEAC claims. * * This attestation provides a standardized way to dispute receipts, * attributions, identity claims, or policy decisions. * * @example * ```typescript * const dispute: DisputeAttestation = { * type: 'peac/dispute', * issuer: 'https://publisher.example.com', * issued_at: '2026-01-06T12:00:00Z', * ref: '01ARZ3NDEKTSV4RRFFQ69G5FAV', * evidence: { * dispute_type: 'unauthorized_access', * target_ref: 'jti:01H5KPT9QZA123456789VWXYZG', * target_type: 'receipt', * grounds: [{ code: 'missing_receipt' }], * description: 'Content was accessed without a valid receipt.', * state: 'filed', * }, * }; * ``` */ export declare const DisputeAttestationSchema: z.ZodObject<{ type: z.ZodLiteral<"peac/dispute">; issuer: z.ZodString; issued_at: z.ZodString; expires_at: z.ZodOptional; ref: z.ZodString; evidence: z.ZodObject<{ dispute_type: z.ZodEnum<{ unauthorized_access: "unauthorized_access"; attribution_missing: "attribution_missing"; attribution_incorrect: "attribution_incorrect"; receipt_invalid: "receipt_invalid"; identity_spoofed: "identity_spoofed"; purpose_mismatch: "purpose_mismatch"; policy_violation: "policy_violation"; other: "other"; }>; target_ref: z.ZodString; target_type: z.ZodEnum<{ receipt: "receipt"; attribution: "attribution"; identity: "identity"; policy: "policy"; }>; grounds: z.ZodArray; evidence_ref: z.ZodOptional; details: z.ZodOptional; }, z.core.$strict>>; description: z.ZodString; supporting_receipts: z.ZodOptional>; supporting_attributions: z.ZodOptional>; supporting_documents: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; description: z.ZodOptional; }, z.core.$strict>>>; contact: z.ZodOptional; value: z.ZodString; }, z.core.$strict>>; state: z.ZodEnum<{ filed: "filed"; acknowledged: "acknowledged"; under_review: "under_review"; escalated: "escalated"; resolved: "resolved"; rejected: "rejected"; appealed: "appealed"; final: "final"; }>; state_changed_at: z.ZodOptional; state_reason: z.ZodOptional; resolution: z.ZodOptional; decided_at: z.ZodString; decided_by: z.ZodString; rationale: z.ZodString; remediation: z.ZodOptional; details: z.ZodString; deadline: z.ZodOptional; }, z.core.$strict>>; }, z.core.$strict>>; window_hint_days: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>; export type DisputeAttestation = z.infer; /** * Validate a DisputeAttestation. * * @param data - Unknown data to validate * @returns Result with validated attestation or error message * * @example * ```typescript * const result = validateDisputeAttestation(data); * if (result.ok) { * console.log('Dispute ref:', result.value.ref); * } else { * console.error('Validation error:', result.error); * } * ``` */ export declare function validateDisputeAttestation(data: unknown): { ok: true; value: DisputeAttestation; } | { ok: false; error: string; }; /** * Check if an object is a valid DisputeAttestation. * * @param data - Unknown data to check * @returns True if valid */ export declare function isValidDisputeAttestation(data: unknown): data is DisputeAttestation; /** * Check if an object has the dispute attestation type. * * @param attestation - Object with a type field * @returns True if type is 'peac/dispute' */ export declare function isDisputeAttestation(attestation: { type: string; }): attestation is DisputeAttestation; /** * Validate a DisputeResolution. * * @param data - Unknown data to validate * @returns Result with validated resolution or error message */ export declare function validateDisputeResolution(data: unknown): { ok: true; value: DisputeResolution; } | { ok: false; error: string; }; /** * Validate a DisputeContact. * * @param data - Unknown data to validate * @returns Result with validated contact or error message */ export declare function validateDisputeContact(data: unknown): { ok: true; value: DisputeContact; } | { ok: false; error: string; }; /** * Parameters for creating a DisputeAttestation. */ export interface CreateDisputeAttestationParams { /** Party filing the dispute */ issuer: string; /** Unique dispute reference (ULID format) */ ref: string; /** Type of dispute */ dispute_type: DisputeType; /** Reference to disputed target */ target_ref: string; /** Type of target */ target_type: DisputeTargetType; /** Grounds for dispute */ grounds: DisputeGrounds[]; /** Human-readable description */ description: string; /** Contact information (optional) */ contact?: DisputeContact; /** When the attestation expires (optional) */ expires_at?: string; /** Supporting receipt references (optional) */ supporting_receipts?: string[]; /** Supporting attribution references (optional) */ supporting_attributions?: string[]; /** Supporting document references (optional) */ supporting_documents?: DocumentRef[]; /** Advisory filing window in days (optional) */ window_hint_days?: number; } /** * Create a DisputeAttestation with current timestamp and 'filed' state. * * @param params - Attestation parameters * @returns A valid DisputeAttestation in 'filed' state * * @example * ```typescript * const dispute = createDisputeAttestation({ * issuer: 'https://publisher.example.com', * ref: '01ARZ3NDEKTSV4RRFFQ69G5FAV', * dispute_type: 'unauthorized_access', * target_ref: 'jti:01H5KPT9QZA123456789VWXYZG', * target_type: 'receipt', * grounds: [{ code: 'missing_receipt' }], * description: 'Content was accessed without a valid receipt.', * }); * ``` */ export declare function createDisputeAttestation(params: CreateDisputeAttestationParams): DisputeAttestation; /** * Transition a dispute to a new state. * * @param dispute - Current dispute attestation * @param newState - Target state * @param reason - Reason for transition (optional) * @param resolution - Resolution details (required for terminal states) * @returns Updated dispute attestation or error * * @example * ```typescript * // Acknowledge a filed dispute * const acknowledged = transitionDisputeState( * dispute, * 'acknowledged', * 'Dispute received and under review' * ); * * // Resolve a dispute (terminal state requires resolution) * const resolved = transitionDisputeState( * dispute, * 'resolved', * 'Investigation complete', * { * outcome: 'upheld', * decided_at: new Date().toISOString(), * decided_by: 'https://platform.example.com', * rationale: 'Evidence supports the claim.', * } * ); * ``` */ export declare function transitionDisputeState(dispute: DisputeAttestation, newState: DisputeState, reason?: string, resolution?: DisputeResolution): { ok: true; value: DisputeAttestation; } | { ok: false; error: string; code: 'INVALID_TRANSITION' | 'RESOLUTION_REQUIRED' | 'RESOLUTION_NOT_ALLOWED'; }; /** * Check if a dispute attestation is expired. * * @param attestation - The attestation to check * @param clockSkew - Clock skew tolerance in milliseconds (default: 30000) * @returns True if expired */ export declare function isDisputeExpired(attestation: DisputeAttestation, clockSkew?: number): boolean; /** * Check if a dispute attestation is not yet valid (issued_at in future). * * @param attestation - The attestation to check * @param clockSkew - Clock skew tolerance in milliseconds (default: 30000) * @returns True if not yet valid */ export declare function isDisputeNotYetValid(attestation: DisputeAttestation, clockSkew?: number): boolean; //# sourceMappingURL=dispute.d.ts.map