File size: 1,410 Bytes
518343a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Doctrine V6 receipt classes emitted by this kit.
//
// Every receipt class in this file is on the *critical path* of a sparse-
// attention plan: a sparse plan that lacks an admission receipt cannot
// execute; a contradiction that lacks an escalation receipt is a doctrine
// violation; a router whose recent traces violate its declared envelope is
// auto-demoted at receipt-write time.
//
// Receipts are typed shapes ONLY — the emit/persist transport is owned by
// the api-server. This package never reaches out to a transport.

export const RECEIPT_CLASSES = [
  "sparse.regime.admitted.v1",
  "sparse.regime.rejected.v1",
  "sparse.regime.demoted.v1",
  "sparse.contradiction.v1",
  "sparse.escalated.v1",
  "sparse.index.score.v1",
  "sparse.topk.commit.v1",
  "sparse.execute.v1",
  "sparse.budget.exhausted.v1",
  "sparse.router.trace.v1",
  "sparse.io.budget.v1",
  "sparse.io.overrun.v1",
] as const;

export type SparseReceiptClass = (typeof RECEIPT_CLASSES)[number];

export interface SparseReceiptCommon {
  readonly receiptClass: SparseReceiptClass;
  readonly freshnessNonce: string;
  readonly issuedAt: string; // ISO 8601 UTC
  readonly parentRef?: string; // chain to upstream receipt (e.g. admission → execution)
  readonly tenant: string;
}

export function isSparseReceiptClass(s: string): s is SparseReceiptClass {
  return (RECEIPT_CLASSES as readonly string[]).includes(s);
}