@mnemom/mnemom 0.17.34-next.1 → 0.17.34-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/dist/base-url-proxy.mjs +18 -4
  2. package/dist/commands/agent-config.js +5 -1
  3. package/dist/commands/agent-doctor.d.ts +9 -0
  4. package/dist/commands/agent-doctor.js +4 -0
  5. package/dist/commands/agent-run.d.ts +14 -6
  6. package/dist/commands/agent-run.js +44 -27
  7. package/dist/commands/agent-session.d.ts +1 -2
  8. package/dist/commands/agent-session.js +1 -2
  9. package/dist/commands/agent-setup.d.ts +6 -0
  10. package/dist/commands/agent-setup.js +12 -1
  11. package/dist/commands/agent-share-test-issuer.d.ts +67 -0
  12. package/dist/commands/agent-share-test-issuer.js +139 -0
  13. package/dist/commands/agent-share.d.ts +7 -1
  14. package/dist/commands/agent-share.js +14 -4
  15. package/dist/commands/agent.d.ts +18 -5
  16. package/dist/commands/agent.js +186 -59
  17. package/dist/commands/durable-doctor.d.ts +50 -0
  18. package/dist/commands/durable-doctor.js +186 -0
  19. package/dist/commands/durable-lock.d.ts +261 -0
  20. package/dist/commands/durable-lock.js +600 -0
  21. package/dist/commands/durable-sessions.d.ts +87 -0
  22. package/dist/commands/durable-sessions.js +303 -0
  23. package/dist/commands/durable-verbs.d.ts +116 -0
  24. package/dist/commands/durable-verbs.js +393 -0
  25. package/dist/commands/scan.d.ts +12 -1
  26. package/dist/commands/scan.js +22 -3
  27. package/dist/commands/wrap.js +1 -1
  28. package/dist/durable/adopt-live.js +5 -8
  29. package/dist/durable/adopt.d.ts +8 -0
  30. package/dist/durable/adopt.js +27 -6
  31. package/dist/durable/cwd-rule.d.ts +9 -1
  32. package/dist/durable/cwd-rule.js +18 -0
  33. package/dist/durable/flock.d.ts +26 -0
  34. package/dist/durable/flock.js +80 -0
  35. package/dist/durable/launch-spec.d.ts +9 -1
  36. package/dist/durable/launch-spec.js +11 -4
  37. package/dist/durable/seat-proxy-entry.d.ts +11 -0
  38. package/dist/durable/seat-proxy-entry.js +25 -0
  39. package/dist/durable/seat-proxy.d.ts +107 -0
  40. package/dist/durable/seat-proxy.js +599 -0
  41. package/dist/durable/seat-socket.d.ts +46 -0
  42. package/dist/durable/seat-socket.js +179 -0
  43. package/dist/durable/seat-spec-validator.d.ts +28 -0
  44. package/dist/durable/seat-spec-validator.js +59 -0
  45. package/dist/durable/test-mode.mjs +105 -0
  46. package/dist/durable/turn-chain.d.ts +55 -0
  47. package/dist/durable/turn-chain.js +178 -0
  48. package/dist/host/auto-continue.d.ts +67 -0
  49. package/dist/host/auto-continue.js +118 -0
  50. package/dist/host/bootid.d.ts +13 -0
  51. package/dist/host/bootid.js +41 -0
  52. package/dist/host/client.d.ts +125 -0
  53. package/dist/host/client.js +171 -0
  54. package/dist/host/commands.d.ts +2 -0
  55. package/dist/host/commands.js +122 -0
  56. package/dist/host/control.d.ts +33 -0
  57. package/dist/host/control.js +144 -0
  58. package/dist/host/daemon.d.ts +221 -0
  59. package/dist/host/daemon.js +616 -0
  60. package/dist/host/gate.d.ts +46 -0
  61. package/dist/host/gate.js +82 -0
  62. package/dist/host/grant.d.ts +24 -0
  63. package/dist/host/grant.js +24 -0
  64. package/dist/host/instance.d.ts +35 -0
  65. package/dist/host/instance.js +62 -0
  66. package/dist/host/integrity.d.ts +35 -0
  67. package/dist/host/integrity.js +115 -0
  68. package/dist/host/launchd.d.ts +16 -0
  69. package/dist/host/launchd.js +45 -0
  70. package/dist/host/lock.d.ts +20 -0
  71. package/dist/host/lock.js +63 -0
  72. package/dist/host/owner.d.ts +58 -0
  73. package/dist/host/owner.js +123 -0
  74. package/dist/host/plist.d.ts +16 -0
  75. package/dist/host/plist.js +85 -0
  76. package/dist/host/procs.d.ts +27 -0
  77. package/dist/host/procs.js +105 -0
  78. package/dist/host/run.d.ts +65 -0
  79. package/dist/host/run.js +299 -0
  80. package/dist/host/runtime.d.ts +8 -0
  81. package/dist/host/runtime.js +22 -0
  82. package/dist/host/s1-names.d.ts +23 -0
  83. package/dist/host/s1-names.js +22 -0
  84. package/dist/host/seat-credential.d.ts +27 -0
  85. package/dist/host/seat-credential.js +41 -0
  86. package/dist/host/seat-launch-main.d.ts +1 -0
  87. package/dist/host/seat-launch-main.js +59 -0
  88. package/dist/host/seat-launch.d.ts +116 -0
  89. package/dist/host/seat-launch.js +302 -0
  90. package/dist/host/seat.d.ts +48 -0
  91. package/dist/host/seat.js +149 -0
  92. package/dist/host/state.d.ts +33 -0
  93. package/dist/host/state.js +117 -0
  94. package/dist/host/status.d.ts +101 -0
  95. package/dist/host/status.js +307 -0
  96. package/dist/host/tmux.d.ts +56 -0
  97. package/dist/host/tmux.js +182 -0
  98. package/dist/host/transcript.d.ts +30 -0
  99. package/dist/host/transcript.js +130 -0
  100. package/dist/host/verbs.d.ts +52 -0
  101. package/dist/host/verbs.js +282 -0
  102. package/dist/index.d.ts +8 -6
  103. package/dist/index.js +209 -43
  104. package/dist/lib/agent.d.ts +13 -29
  105. package/dist/lib/agent.js +17 -29
  106. package/dist/lib/claude-bin.d.ts +6 -0
  107. package/dist/lib/claude-bin.js +26 -0
  108. package/dist/lib/claude-plugin.d.ts +11 -2
  109. package/dist/lib/claude-plugin.js +10 -1
  110. package/dist/lib/commit-report.d.ts +5 -4
  111. package/dist/lib/commit-report.js +6 -9
  112. package/dist/lib/config.d.ts +8 -1
  113. package/dist/lib/config.js +28 -0
  114. package/dist/lib/durable/api.d.ts +136 -0
  115. package/dist/lib/durable/api.js +220 -0
  116. package/dist/lib/durable/codes.d.ts +8 -0
  117. package/dist/lib/durable/codes.js +2 -0
  118. package/dist/lib/durable/gate.d.ts +48 -0
  119. package/dist/lib/durable/gate.js +122 -0
  120. package/dist/lib/durable/handover.d.ts +101 -0
  121. package/dist/lib/durable/handover.js +175 -0
  122. package/dist/lib/durable/launch.d.ts +199 -0
  123. package/dist/lib/durable/launch.js +461 -0
  124. package/dist/lib/durable/launching.d.ts +15 -0
  125. package/dist/lib/durable/launching.js +70 -0
  126. package/dist/lib/durable/live.d.ts +190 -0
  127. package/dist/lib/durable/live.js +633 -0
  128. package/dist/lib/durable/refusal.d.ts +57 -0
  129. package/dist/lib/durable/refusal.js +78 -0
  130. package/dist/lib/durable/view.d.ts +83 -0
  131. package/dist/lib/durable/view.js +244 -0
  132. package/dist/lib/experimental.d.ts +0 -9
  133. package/dist/lib/experimental.js +18 -17
  134. package/dist/lib/launcher-config.d.ts +13 -0
  135. package/dist/lib/launcher-config.js +32 -0
  136. package/dist/lib/runner/exec-append.d.ts +15 -0
  137. package/dist/lib/runner/exec-append.js +2 -0
  138. package/dist/lib/runner/executor-client.d.ts +2 -1
  139. package/dist/lib/runner/executor-state.d.ts +10 -0
  140. package/dist/lib/runner/executor-state.js +24 -0
  141. package/dist/lib/runner/github-base.d.ts +24 -0
  142. package/dist/lib/runner/github-base.js +27 -0
  143. package/dist/lib/runner/job.d.ts +9 -4
  144. package/dist/lib/runner/job.js +43 -15
  145. package/dist/lib/runner/oidc.d.ts +3 -2
  146. package/dist/lib/runner/oidc.js +7 -4
  147. package/dist/lib/runner/options.d.ts +6 -0
  148. package/dist/lib/runner/options.js +19 -1
  149. package/dist/lib/runner/phases.d.ts +7 -4
  150. package/dist/lib/runner/phases.js +8 -4
  151. package/dist/lib/runner/proxy.d.ts +5 -1
  152. package/dist/lib/runner/proxy.js +7 -1
  153. package/dist/lib/scan/cost-per-pr.d.ts +93 -0
  154. package/dist/lib/scan/cost-per-pr.js +101 -0
  155. package/dist/lib/scan/record.d.ts +27 -1
  156. package/dist/lib/scan/record.js +114 -16
  157. package/dist/lib/scan/report-email.d.ts +26 -6
  158. package/dist/lib/scan/report-email.js +32 -3
  159. package/dist/lib/scan/scan.d.ts +3 -0
  160. package/dist/lib/scan/scan.js +13 -1
  161. package/dist/lib/subscription-login.d.ts +15 -0
  162. package/dist/lib/subscription-login.js +28 -1
  163. package/dist/vendor/durable-contract/index.js +240 -18
  164. package/dist/vendor/shared/durable-contract/admission.d.ts +240 -0
  165. package/dist/vendor/shared/durable-contract/admission.js +533 -0
  166. package/dist/vendor/shared/durable-contract/arm.d.ts +51 -0
  167. package/dist/vendor/shared/durable-contract/arm.js +133 -0
  168. package/dist/vendor/shared/durable-contract/canonical.d.ts +29 -0
  169. package/dist/vendor/shared/durable-contract/canonical.js +98 -0
  170. package/dist/vendor/shared/durable-contract/cell-id.d.ts +22 -0
  171. package/dist/vendor/shared/durable-contract/cell-id.js +38 -0
  172. package/dist/vendor/shared/durable-contract/cli-output.d.ts +342 -0
  173. package/dist/vendor/shared/durable-contract/cli-output.js +201 -0
  174. package/dist/vendor/shared/durable-contract/cli-surface.d.ts +119 -0
  175. package/dist/vendor/shared/durable-contract/cli-surface.js +270 -0
  176. package/dist/vendor/shared/durable-contract/codes.d.ts +537 -0
  177. package/dist/vendor/shared/durable-contract/codes.js +475 -0
  178. package/dist/vendor/shared/durable-contract/constants.d.ts +153 -0
  179. package/dist/vendor/shared/durable-contract/constants.js +179 -0
  180. package/dist/vendor/shared/durable-contract/doors.d.ts +119 -0
  181. package/dist/vendor/shared/durable-contract/doors.js +249 -0
  182. package/dist/vendor/shared/durable-contract/envelope.d.ts +103 -0
  183. package/dist/vendor/shared/durable-contract/envelope.js +317 -0
  184. package/dist/vendor/shared/durable-contract/events.d.ts +147 -0
  185. package/dist/vendor/shared/durable-contract/events.js +630 -0
  186. package/dist/vendor/shared/durable-contract/executor-state.d.ts +41 -0
  187. package/dist/vendor/shared/durable-contract/executor-state.js +32 -0
  188. package/dist/vendor/shared/durable-contract/fixlines.d.ts +318 -0
  189. package/dist/vendor/shared/durable-contract/fixlines.js +483 -0
  190. package/dist/vendor/shared/durable-contract/freeze-record.d.ts +787 -0
  191. package/dist/vendor/shared/durable-contract/freeze-record.js +361 -0
  192. package/dist/vendor/shared/durable-contract/index.d.ts +36 -0
  193. package/dist/vendor/shared/durable-contract/index.js +37 -0
  194. package/dist/vendor/shared/durable-contract/journal-approvals.d.ts +29 -0
  195. package/dist/vendor/shared/durable-contract/journal-approvals.js +60 -0
  196. package/dist/vendor/shared/durable-contract/keys.d.ts +24 -0
  197. package/dist/vendor/shared/durable-contract/keys.js +66 -0
  198. package/dist/vendor/shared/durable-contract/lock.d.ts +128 -0
  199. package/dist/vendor/shared/durable-contract/lock.js +151 -0
  200. package/dist/vendor/shared/durable-contract/names.d.ts +25 -0
  201. package/dist/vendor/shared/durable-contract/names.js +78 -0
  202. package/dist/vendor/shared/durable-contract/owner-verbs.d.ts +175 -0
  203. package/dist/vendor/shared/durable-contract/owner-verbs.js +403 -0
  204. package/dist/vendor/shared/durable-contract/paths.d.ts +23 -0
  205. package/dist/vendor/shared/durable-contract/paths.js +35 -0
  206. package/dist/vendor/shared/durable-contract/pure-fn.d.ts +48 -0
  207. package/dist/vendor/shared/durable-contract/pure-fn.js +89 -0
  208. package/dist/vendor/shared/durable-contract/routes.d.ts +205 -0
  209. package/dist/vendor/shared/durable-contract/routes.js +315 -0
  210. package/dist/vendor/shared/durable-contract/schema.d.ts +126 -0
  211. package/dist/vendor/shared/durable-contract/schema.js +441 -0
  212. package/dist/vendor/shared/durable-contract/seal.d.ts +54 -0
  213. package/dist/vendor/shared/durable-contract/seal.js +99 -0
  214. package/dist/vendor/shared/durable-contract/secret-scope.d.ts +28 -0
  215. package/dist/vendor/shared/durable-contract/secret-scope.js +76 -0
  216. package/dist/vendor/shared/durable-contract/session-id.d.ts +21 -0
  217. package/dist/vendor/shared/durable-contract/session-id.js +58 -0
  218. package/dist/vendor/shared/durable-contract/spec.d.ts +162 -0
  219. package/dist/vendor/shared/durable-contract/spec.js +286 -0
  220. package/dist/vendor/shared/durable-contract/states.d.ts +96 -0
  221. package/dist/vendor/shared/durable-contract/states.js +218 -0
  222. package/dist/vendor/shared/durable-contract/telemetry.d.ts +94 -0
  223. package/dist/vendor/shared/durable-contract/telemetry.js +180 -0
  224. package/dist/vendor/shared/durable-contract/test-mode.d.ts +62 -0
  225. package/dist/vendor/shared/durable-contract/test-mode.js +140 -0
  226. package/dist/vendor/shared/durable-contract/turn.d.ts +57 -0
  227. package/dist/vendor/shared/durable-contract/turn.js +81 -0
  228. package/dist/vendor/shared/durable-contract/vectors.d.ts +191 -0
  229. package/dist/vendor/shared/durable-contract/vectors.js +208 -0
  230. package/package.json +3 -2
  231. package/plugins/integrity-manifest.json +35 -0
  232. package/plugins/mnemom/hooks/hooks.json +15 -1
  233. package/plugins/mnemom/hooks/register.tsx +60 -2
  234. package/plugins/mnemom/hooks/seat-hello.mjs +116 -0
  235. package/dist/commands/agent-implicit-notice.d.ts +0 -31
  236. package/dist/commands/agent-implicit-notice.js +0 -73
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Gateway admission for mnm_ds_ keys: one total pure function over the resolver's `durable`
3
+ * object plus the request pin and posture (design §3.6 steps 1-4; C06-R14/R15; C08-R13/R14;
4
+ * C09-R08/R11; C11-R33; rulings I03, I12, I20, r3 I01). Data, not branches, wherever possible:
5
+ * ADMISSION_PRECEDENCE is the order the oracle reads, and `admissionTruthTable()` enumerates the
6
+ * cross product the eval compares against.
7
+ *
8
+ * Precedence, first match wins:
9
+ * 1 unknown or invalid key -> the baseline unknown-key answer for the path and mode
10
+ * 2 resolver fault or bad schema -> 503 durable_admission_unavailable
11
+ * 3 key_state revoked -> 401 durable_key_revoked
12
+ * 4 pin absent or mismatched -> 409 durable_identity_mismatch
13
+ * 5 durable_mode tracked -> 410 durable_unlocked
14
+ * 6 effective terminal -> 410 durable_session_ended {state, state_reason}
15
+ * 7 fenced (unless nofence) -> 409 durable_lease_fenced
16
+ * 8 paused or non-admitting suspended -> 423 durable_session_stopped {state, state_reason}
17
+ * 9 posture: attended admits; unattended -> 503 durable_guard_unavailable on a guard fault,
18
+ * else 503 durable_unattended_unavailable (M1 refuses all unattended work).
19
+ * The one exception (wave-0 fix ruling 22): a POST /v1/messages/count_tokens with no chain= (header
20
+ * absent, or no chain on the newest entry) runs steps 1-8 and skips step 9: it is admitted as
21
+ * admit_unchained, with no chain row and no posture insert. Every other request is unchanged.
22
+ * Hello transition: only an admitted attended request moves an effectively resuming session to
23
+ * running (helloTransition). admit_unchained never does and writes nothing (a resuming session
24
+ * stays resuming).
25
+ * The door (normalizeCellId(CELL_ID) vs home_cell) is diagnostic only in M1.
26
+ * An attended guard fault is admitted (today's behaviour) and reported (C08-R14).
27
+ */
28
+ import type { GatewayRefusalCode } from "./codes.js";
29
+ import { type EffectiveState, type SessionState, type StateReason } from "./states.js";
30
+ import { type CanonicalCellId } from "./cell-id.js";
31
+ export declare const KEY_STATES: readonly ["active", "revoked"];
32
+ export type KeyState = (typeof KEY_STATES)[number];
33
+ export declare const POSTURES: readonly ["attended", "unattended"];
34
+ export type Posture = (typeof POSTURES)[number];
35
+ export declare const EXECUTOR_KINDS: readonly ["host", "fleet", "container"];
36
+ export type ExecutorKind = (typeof EXECUTOR_KINDS)[number];
37
+ export declare const OUTAGE_MODES: readonly ["stop", "continue"];
38
+ /** Field types of the resolver's `durable` object (the per-field schema, C06-R15). */
39
+ export type FieldType = "uuid" | "string" | "boolean" | "integer" | "timestamp" | "object" | "enum";
40
+ export interface FieldSpec {
41
+ readonly type: FieldType;
42
+ readonly nullable: boolean;
43
+ /** For enum fields: the closed value set. */
44
+ readonly values?: readonly string[];
45
+ /** What null means, for a nullable field. */
46
+ readonly nullMeans?: string;
47
+ }
48
+ /**
49
+ * The resolver per-field schema. A missing field, wrong type, unknown enum value, or null on a
50
+ * non-nullable field is a schema fault: 503 durable_admission_unavailable, never a throw.
51
+ */
52
+ export declare const RESOLVER_SCHEMA: Readonly<Record<string, FieldSpec>>;
53
+ export interface ResolverDurable {
54
+ key_state: KeyState;
55
+ session_id: string;
56
+ aip_session_id: string;
57
+ durable_mode: "tracked" | "locked";
58
+ state: SessionState;
59
+ effective_state: EffectiveState;
60
+ state_reason: StateReason | null;
61
+ epoch: number;
62
+ fenced: boolean;
63
+ agent_id: string;
64
+ home_cell: CanonicalCellId;
65
+ posture: Posture | null;
66
+ executor_kind: ExecutorKind;
67
+ host_unattended: boolean;
68
+ unattended_enabled: boolean;
69
+ grant_live: boolean;
70
+ expires_at: string | null;
71
+ lease_expires_at: string | null;
72
+ lease_executor_id: string | null;
73
+ attach_until: string | null;
74
+ attach_live: boolean | null;
75
+ sealed: boolean;
76
+ outage_mode: "stop" | "continue" | null;
77
+ charter_hash: string | null;
78
+ guard_state: Record<string, unknown> | null;
79
+ has_pointer: boolean;
80
+ }
81
+ /** One resolver field against its spec (pure; exported for its direct test). */
82
+ export declare function fieldOk(spec: FieldSpec, v: unknown): boolean;
83
+ /**
84
+ * Validate a resolver answer. Returns the typed object, or null for any schema fault (missing
85
+ * field, wrong type, unknown enum, null on non-nullable, an illegal state_reason for the state, an
86
+ * effective state the derivation cannot produce, or a locked row with no charter).
87
+ */
88
+ export declare function parseResolverDurable(raw: unknown): ResolverDurable | null;
89
+ /** Whether a locked session's guard_state is usable (C08-R13): an object carrying numeric spend_usd. */
90
+ export declare function guardStateOk(guard: Record<string, unknown> | null): boolean;
91
+ /**
92
+ * Canonical guard_state fixtures for the case datasets (`$S1.GUARD_STATE_OK` / `$S1.GUARD_STATE_FAULT`,
93
+ * written as jsonb): OK passes guardStateOk; FAULT is a present object of the wrong shape (spend_usd
94
+ * not a number), the C08-R13 / claim check 7 fault, never null so it exercises the shape check.
95
+ */
96
+ export declare const GUARD_STATE_OK: Readonly<{
97
+ spend_usd: number;
98
+ }>;
99
+ export declare const GUARD_STATE_FAULT: Readonly<{
100
+ spend_usd: string;
101
+ }>;
102
+ /** Whether DURABLE_ADMIT is honoured: only the exact bytes "nofence" (NOFENCE_M1, r3 I01). */
103
+ export declare function nofenceHonoured(durableAdmit: string | undefined): boolean;
104
+ export type AdmissionStep = "unknown_key" | "resolver_fault" | "revoked" | "identity" | "tracked" | "terminal" | "fenced" | "stopped" | "posture" | "admit";
105
+ /** The order the oracle reads (C11-R33). */
106
+ export declare const ADMISSION_PRECEDENCE: readonly AdmissionStep[];
107
+ export declare const ADMISSION_STEP_CODE: {
108
+ readonly [S in Exclude<AdmissionStep, "unknown_key" | "posture" | "admit">]: GatewayRefusalCode;
109
+ };
110
+ /** Persisted or effective states that admit an attended chain (design §3.6 step 4 table). */
111
+ export declare function attendedAdmits(effective: EffectiveState, reason: StateReason | null): boolean;
112
+ export type FenceSource = "fresh" | "nofence";
113
+ /** The count_tokens route (wave-0 fix ruling 22), path without a query string, as the proxy sends it upstream. */
114
+ export declare const COUNT_TOKENS_PATH = "/v1/messages/count_tokens";
115
+ /** The same route at the gateway door (provider-prefixed). */
116
+ export declare const GATEWAY_COUNT_TOKENS_PATH = "/anthropic/v1/messages/count_tokens";
117
+ /** Whether a path (no query string) is the count_tokens route, bare or at the gateway door. */
118
+ export declare function isCountTokensPath(path: string): boolean;
119
+ /** The request facts admission needs beyond the key (wave-0 fix ruling 22). */
120
+ export interface AdmissionRequest {
121
+ method: string;
122
+ /** The request path without a query string. */
123
+ path: string;
124
+ /** Whether a chain= element was sent on the newest x-mnemom-turn entry (false: header absent or no chain). */
125
+ chain: boolean;
126
+ }
127
+ /** Whether a request skips the posture step: POST /v1/messages/count_tokens with no chain (ruling 22). */
128
+ export declare function isUnchainedCountTokens(r: AdmissionRequest): boolean;
129
+ export interface AdmissionInput {
130
+ /** null: no row for the key hash (unknown or invalid key). "fault": resolver down, hung, 5xx, PGRST202 or malformed. */
131
+ resolver: unknown;
132
+ /** x-mnemom-agent-id as sent (null when absent). */
133
+ pinAgentId: string | null;
134
+ /** The chain posture the resolver returned, else the candidate (unknown = unattended). */
135
+ posture: Posture | null;
136
+ durableAdmit: string | undefined;
137
+ /** The request (ruling 22). Absent: decided as any request other than an unchained count_tokens. */
138
+ request?: AdmissionRequest;
139
+ }
140
+ export type AdmissionVerdict = {
141
+ kind: "baseline_unknown_key";
142
+ step: "unknown_key";
143
+ } | {
144
+ kind: "refuse";
145
+ step: Exclude<AdmissionStep, "unknown_key" | "admit">;
146
+ code: GatewayRefusalCode;
147
+ state?: SessionState;
148
+ state_reason?: string | null;
149
+ posture: Posture;
150
+ fenceSource: FenceSource;
151
+ } | {
152
+ kind: "admit";
153
+ step: "admit";
154
+ posture: "attended";
155
+ guardFault: boolean;
156
+ fenceSource: FenceSource;
157
+ /** True when the session is effectively resuming: this request moves it to running. */
158
+ helloTransition: boolean;
159
+ } | {
160
+ /** Ruling 22: an unchained count_tokens passed steps 1-8; the gateway writes no chain row and no posture.
161
+ * Its response arm is m1Arm(durableAdmit, "none") (ruling 22.1). */
162
+ kind: "admit_unchained";
163
+ step: "admit";
164
+ posture: null;
165
+ guardFault: boolean;
166
+ fenceSource: FenceSource;
167
+ /** Never: a resuming session stays resuming. */
168
+ helloTransition: false;
169
+ /** The gateway writes nothing for it (no chain row, no posture, no state change). */
170
+ writes: false;
171
+ };
172
+ export declare const RESOLVER_FAULT: "fault";
173
+ /** The admission function. Total: every input maps to exactly one verdict; it never throws. */
174
+ export declare function admit(input: AdmissionInput): AdmissionVerdict;
175
+ export declare const ADMISSION_REQUEST_KINDS: readonly ["standard", "count_tokens_unchained"];
176
+ export type AdmissionRequestKind = (typeof ADMISSION_REQUEST_KINDS)[number];
177
+ export interface TruthRow {
178
+ state: SessionState;
179
+ state_reason: StateReason | null;
180
+ effective_state: EffectiveState;
181
+ fenced: boolean;
182
+ key_state: KeyState;
183
+ durable_mode: "tracked" | "locked";
184
+ posture: Posture;
185
+ guard_ok: boolean;
186
+ nofence: boolean;
187
+ pin: "match" | "absent" | "mismatch";
188
+ /** standard: any request but an unchained count_tokens; count_tokens_unchained: ruling 22. */
189
+ request: AdmissionRequestKind;
190
+ /** Whether the request moves the session from resuming to running (an attended admit only). */
191
+ hello_transition: boolean;
192
+ /** "admit", "admit_unchained", "baseline_unknown_key" or the refusal code. */
193
+ outcome: string;
194
+ status: number | null;
195
+ }
196
+ /** HTTP status of a truth-table outcome (null = the baseline unknown-key answer); throws on an unknown outcome. */
197
+ export declare function admissionStatusOf(outcome: string): number | null;
198
+ /** A well-formed resolver object for a row of the truth table. */
199
+ export declare function fixtureResolver(over?: Partial<ResolverDurable>): ResolverDurable;
200
+ /** Every (persisted state, reason) pair, with its persisted effective state and the derived ones. */
201
+ export declare function stateRows(): {
202
+ state: SessionState;
203
+ state_reason: StateReason | null;
204
+ effective_state: EffectiveState;
205
+ }[];
206
+ /** The full cross product over the admission dimensions, each row decided by `admit`. */
207
+ export declare function admissionTruthTable(): TruthRow[];
208
+ /** Golden vectors: a 3-dim toy sweep (every line) and C06 SWEEP_A (count, first 3 lines, digest). */
209
+ export declare const ADMIT_SWEEP_VECTORS_PATH = "src/vectors/admit-sweep-vectors.json";
210
+ /**
211
+ * A pure admission sweep as the C06 case passes it: `dims` is an ORDERED array (an object's key
212
+ * order does not survive canonicalisation, so it is refused). Each dimension names a resolver or
213
+ * request input in the C06 case vocabulary; see ADMIT_SWEEP_VALUES.
214
+ */
215
+ export interface AdmitSweep {
216
+ readonly name: string;
217
+ readonly dims: readonly {
218
+ readonly name: string;
219
+ readonly values: readonly unknown[];
220
+ }[];
221
+ }
222
+ /**
223
+ * The closed value set of each C06 sweep dimension (gen/fam-a.mjs SWEEP_A / SWEEP_B vocabulary).
224
+ * A null on a non-nullable resolver field reaches admit() as that null (a schema fault, 503).
225
+ * stored_state is "state" or "state:reason" ("null" for a NULL reason), state a SESSION_STATES value.
226
+ */
227
+ export declare const ADMIT_SWEEP_VALUES: Readonly<Record<string, readonly unknown[]>>;
228
+ /**
229
+ * The sweep's verdict text: an odometer over `dims` (first entry slowest, values in array order),
230
+ * one sweepLine per tuple, each followed by LF (also after the last). Throws on a bad sweep.
231
+ */
232
+ export declare function admitSweepText(sweep: AdmitSweep): {
233
+ tuples: number;
234
+ text: string;
235
+ };
236
+ /** verdicts_sha256: lowercase hex sha256 of the UTF-8 bytes of admitSweepText(sweep).text. */
237
+ export declare function admitSweepDigest(sweep: AdmitSweep): Promise<{
238
+ tuples: number;
239
+ verdicts_sha256: string;
240
+ }>;