@mnemom/mnemom 0.17.34-next.1 → 0.17.34-next.2
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.
- package/dist/base-url-proxy.mjs +18 -4
- package/dist/commands/agent-config.js +5 -1
- package/dist/commands/agent-doctor.d.ts +9 -0
- package/dist/commands/agent-doctor.js +4 -0
- package/dist/commands/agent-session.d.ts +1 -2
- package/dist/commands/agent-session.js +1 -2
- package/dist/commands/agent-setup.d.ts +6 -0
- package/dist/commands/agent-setup.js +12 -1
- package/dist/commands/agent.d.ts +11 -0
- package/dist/commands/agent.js +145 -46
- package/dist/commands/durable-doctor.d.ts +50 -0
- package/dist/commands/durable-doctor.js +186 -0
- package/dist/commands/durable-lock.d.ts +254 -0
- package/dist/commands/durable-lock.js +595 -0
- package/dist/commands/durable-sessions.d.ts +87 -0
- package/dist/commands/durable-sessions.js +303 -0
- package/dist/commands/durable-verbs.d.ts +116 -0
- package/dist/commands/durable-verbs.js +393 -0
- package/dist/durable/flock.d.ts +26 -0
- package/dist/durable/flock.js +80 -0
- package/dist/durable/launch-spec.d.ts +7 -1
- package/dist/durable/launch-spec.js +10 -3
- package/dist/durable/seat-proxy-entry.d.ts +11 -0
- package/dist/durable/seat-proxy-entry.js +25 -0
- package/dist/durable/seat-proxy.d.ts +107 -0
- package/dist/durable/seat-proxy.js +599 -0
- package/dist/durable/seat-socket.d.ts +46 -0
- package/dist/durable/seat-socket.js +179 -0
- package/dist/durable/seat-spec-validator.d.ts +28 -0
- package/dist/durable/seat-spec-validator.js +59 -0
- package/dist/durable/test-mode.mjs +81 -0
- package/dist/durable/turn-chain.d.ts +55 -0
- package/dist/durable/turn-chain.js +178 -0
- package/dist/host/auto-continue.d.ts +67 -0
- package/dist/host/auto-continue.js +118 -0
- package/dist/host/bootid.d.ts +13 -0
- package/dist/host/bootid.js +41 -0
- package/dist/host/client.d.ts +123 -0
- package/dist/host/client.js +171 -0
- package/dist/host/commands.d.ts +2 -0
- package/dist/host/commands.js +122 -0
- package/dist/host/control.d.ts +33 -0
- package/dist/host/control.js +144 -0
- package/dist/host/daemon.d.ts +217 -0
- package/dist/host/daemon.js +606 -0
- package/dist/host/gate.d.ts +46 -0
- package/dist/host/gate.js +82 -0
- package/dist/host/grant.d.ts +24 -0
- package/dist/host/grant.js +24 -0
- package/dist/host/instance.d.ts +35 -0
- package/dist/host/instance.js +62 -0
- package/dist/host/integrity.d.ts +35 -0
- package/dist/host/integrity.js +115 -0
- package/dist/host/launchd.d.ts +16 -0
- package/dist/host/launchd.js +45 -0
- package/dist/host/lock.d.ts +20 -0
- package/dist/host/lock.js +63 -0
- package/dist/host/owner.d.ts +55 -0
- package/dist/host/owner.js +121 -0
- package/dist/host/plist.d.ts +16 -0
- package/dist/host/plist.js +85 -0
- package/dist/host/procs.d.ts +27 -0
- package/dist/host/procs.js +105 -0
- package/dist/host/run.d.ts +66 -0
- package/dist/host/run.js +314 -0
- package/dist/host/runtime.d.ts +8 -0
- package/dist/host/runtime.js +22 -0
- package/dist/host/s1-names.d.ts +22 -0
- package/dist/host/s1-names.js +21 -0
- package/dist/host/seat-credential.d.ts +27 -0
- package/dist/host/seat-credential.js +41 -0
- package/dist/host/seat-launch-main.d.ts +1 -0
- package/dist/host/seat-launch-main.js +59 -0
- package/dist/host/seat-launch.d.ts +116 -0
- package/dist/host/seat-launch.js +302 -0
- package/dist/host/seat.d.ts +48 -0
- package/dist/host/seat.js +149 -0
- package/dist/host/state.d.ts +33 -0
- package/dist/host/state.js +117 -0
- package/dist/host/status.d.ts +101 -0
- package/dist/host/status.js +307 -0
- package/dist/host/tmux.d.ts +56 -0
- package/dist/host/tmux.js +182 -0
- package/dist/host/transcript.d.ts +30 -0
- package/dist/host/transcript.js +130 -0
- package/dist/host/verbs.d.ts +50 -0
- package/dist/host/verbs.js +271 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +197 -35
- package/dist/lib/agent.d.ts +8 -26
- package/dist/lib/agent.js +11 -26
- package/dist/lib/claude-plugin.d.ts +11 -2
- package/dist/lib/claude-plugin.js +10 -1
- package/dist/lib/durable/api.d.ts +136 -0
- package/dist/lib/durable/api.js +220 -0
- package/dist/lib/durable/codes.d.ts +8 -0
- package/dist/lib/durable/codes.js +2 -0
- package/dist/lib/durable/first-turn.d.ts +50 -0
- package/dist/lib/durable/first-turn.js +102 -0
- package/dist/lib/durable/gate.d.ts +48 -0
- package/dist/lib/durable/gate.js +122 -0
- package/dist/lib/durable/handover.d.ts +101 -0
- package/dist/lib/durable/handover.js +175 -0
- package/dist/lib/durable/launch.d.ts +182 -0
- package/dist/lib/durable/launch.js +443 -0
- package/dist/lib/durable/launching.d.ts +15 -0
- package/dist/lib/durable/launching.js +70 -0
- package/dist/lib/durable/live.d.ts +194 -0
- package/dist/lib/durable/live.js +635 -0
- package/dist/lib/durable/refusal.d.ts +57 -0
- package/dist/lib/durable/refusal.js +78 -0
- package/dist/lib/durable/view.d.ts +83 -0
- package/dist/lib/durable/view.js +244 -0
- package/dist/lib/experimental.d.ts +0 -9
- package/dist/lib/experimental.js +18 -17
- package/dist/lib/launcher-config.d.ts +7 -0
- package/dist/lib/launcher-config.js +21 -0
- package/dist/lib/scan/report-email.d.ts +1 -1
- package/dist/lib/scan/report-email.js +9 -1
- package/dist/lib/subscription-login.d.ts +15 -0
- package/dist/lib/subscription-login.js +28 -1
- package/dist/vendor/durable-contract/index.js +240 -18
- package/dist/vendor/shared/durable-contract/admission.d.ts +240 -0
- package/dist/vendor/shared/durable-contract/admission.js +533 -0
- package/dist/vendor/shared/durable-contract/arm.d.ts +51 -0
- package/dist/vendor/shared/durable-contract/arm.js +133 -0
- package/dist/vendor/shared/durable-contract/canonical.d.ts +29 -0
- package/dist/vendor/shared/durable-contract/canonical.js +98 -0
- package/dist/vendor/shared/durable-contract/cell-id.d.ts +22 -0
- package/dist/vendor/shared/durable-contract/cell-id.js +38 -0
- package/dist/vendor/shared/durable-contract/cli-output.d.ts +342 -0
- package/dist/vendor/shared/durable-contract/cli-output.js +201 -0
- package/dist/vendor/shared/durable-contract/cli-surface.d.ts +119 -0
- package/dist/vendor/shared/durable-contract/cli-surface.js +270 -0
- package/dist/vendor/shared/durable-contract/codes.d.ts +537 -0
- package/dist/vendor/shared/durable-contract/codes.js +475 -0
- package/dist/vendor/shared/durable-contract/constants.d.ts +153 -0
- package/dist/vendor/shared/durable-contract/constants.js +179 -0
- package/dist/vendor/shared/durable-contract/doors.d.ts +119 -0
- package/dist/vendor/shared/durable-contract/doors.js +249 -0
- package/dist/vendor/shared/durable-contract/envelope.d.ts +103 -0
- package/dist/vendor/shared/durable-contract/envelope.js +317 -0
- package/dist/vendor/shared/durable-contract/events.d.ts +147 -0
- package/dist/vendor/shared/durable-contract/events.js +630 -0
- package/dist/vendor/shared/durable-contract/executor-state.d.ts +41 -0
- package/dist/vendor/shared/durable-contract/executor-state.js +32 -0
- package/dist/vendor/shared/durable-contract/fixlines.d.ts +318 -0
- package/dist/vendor/shared/durable-contract/fixlines.js +483 -0
- package/dist/vendor/shared/durable-contract/freeze-record.d.ts +787 -0
- package/dist/vendor/shared/durable-contract/freeze-record.js +361 -0
- package/dist/vendor/shared/durable-contract/index.d.ts +36 -0
- package/dist/vendor/shared/durable-contract/index.js +37 -0
- package/dist/vendor/shared/durable-contract/journal-approvals.d.ts +29 -0
- package/dist/vendor/shared/durable-contract/journal-approvals.js +60 -0
- package/dist/vendor/shared/durable-contract/keys.d.ts +24 -0
- package/dist/vendor/shared/durable-contract/keys.js +66 -0
- package/dist/vendor/shared/durable-contract/lock.d.ts +128 -0
- package/dist/vendor/shared/durable-contract/lock.js +151 -0
- package/dist/vendor/shared/durable-contract/names.d.ts +25 -0
- package/dist/vendor/shared/durable-contract/names.js +78 -0
- package/dist/vendor/shared/durable-contract/owner-verbs.d.ts +175 -0
- package/dist/vendor/shared/durable-contract/owner-verbs.js +403 -0
- package/dist/vendor/shared/durable-contract/paths.d.ts +23 -0
- package/dist/vendor/shared/durable-contract/paths.js +35 -0
- package/dist/vendor/shared/durable-contract/pure-fn.d.ts +48 -0
- package/dist/vendor/shared/durable-contract/pure-fn.js +89 -0
- package/dist/vendor/shared/durable-contract/routes.d.ts +205 -0
- package/dist/vendor/shared/durable-contract/routes.js +315 -0
- package/dist/vendor/shared/durable-contract/schema.d.ts +126 -0
- package/dist/vendor/shared/durable-contract/schema.js +441 -0
- package/dist/vendor/shared/durable-contract/seal.d.ts +54 -0
- package/dist/vendor/shared/durable-contract/seal.js +99 -0
- package/dist/vendor/shared/durable-contract/secret-scope.d.ts +28 -0
- package/dist/vendor/shared/durable-contract/secret-scope.js +76 -0
- package/dist/vendor/shared/durable-contract/session-id.d.ts +21 -0
- package/dist/vendor/shared/durable-contract/session-id.js +58 -0
- package/dist/vendor/shared/durable-contract/spec.d.ts +162 -0
- package/dist/vendor/shared/durable-contract/spec.js +286 -0
- package/dist/vendor/shared/durable-contract/states.d.ts +96 -0
- package/dist/vendor/shared/durable-contract/states.js +218 -0
- package/dist/vendor/shared/durable-contract/telemetry.d.ts +94 -0
- package/dist/vendor/shared/durable-contract/telemetry.js +180 -0
- package/dist/vendor/shared/durable-contract/test-mode.d.ts +62 -0
- package/dist/vendor/shared/durable-contract/test-mode.js +140 -0
- package/dist/vendor/shared/durable-contract/turn.d.ts +57 -0
- package/dist/vendor/shared/durable-contract/turn.js +81 -0
- package/dist/vendor/shared/durable-contract/vectors.d.ts +191 -0
- package/dist/vendor/shared/durable-contract/vectors.js +208 -0
- package/package.json +3 -2
- package/plugins/integrity-manifest.json +35 -0
- package/plugins/mnemom/hooks/hooks.json +15 -1
- package/plugins/mnemom/hooks/register.tsx +60 -2
- package/plugins/mnemom/hooks/seat-hello.mjs +116 -0
- package/dist/commands/agent-implicit-notice.d.ts +0 -31
- package/dist/commands/agent-implicit-notice.js +0 -73
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
// GENERATED from shared/durable-contract/src/codes.ts by cli/scripts/sync-durable-contract.mjs; do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Durable error codes, their HTTP statuses and their closed body fields (BACKBONE codes list,
|
|
4
|
+
* amendments; C06, C10, C11, C16, C19). The body is the shipped error envelope (ruling 14; mnemom-api
|
|
5
|
+
* src/http-errors.ts buildErrorBody, which the gateway uses too):
|
|
6
|
+
* `{error: {code: <code>, message, details?: {fix?, ...closed fields}}}`; durableErrorBody builds it.
|
|
7
|
+
* The RFC 8628 poll endpoints (ENROLL_POLL_ERRORS, the OAuth device token poll) keep
|
|
8
|
+
* `{error: <string>}`.
|
|
9
|
+
*/
|
|
10
|
+
import { fieldOk } from "./admission.js";
|
|
11
|
+
import { PARKED_ONLY_WAIT_REASONS, STATE_REASONS, TERMINAL_STATES, } from "./states.js";
|
|
12
|
+
export const CLAIM_UNAVAILABLE_CAUSES = [
|
|
13
|
+
"schema",
|
|
14
|
+
"arm_probe",
|
|
15
|
+
"entitlement_lookup",
|
|
16
|
+
"protection_probe",
|
|
17
|
+
"guard",
|
|
18
|
+
/** A pool claim with no valid registry default cap (ruling 34.05.1 (3)). */
|
|
19
|
+
"lease_cap_config",
|
|
20
|
+
];
|
|
21
|
+
export const UNSUPPORTED_FEATURES = [
|
|
22
|
+
"tool_classes",
|
|
23
|
+
"launch_spec_change",
|
|
24
|
+
"above_limit_raise",
|
|
25
|
+
"remote_control",
|
|
26
|
+
];
|
|
27
|
+
export const CWD_KINDS = ["subdirectory", "not_git", "symlink_transcript"];
|
|
28
|
+
/** Attestation check `cwd` (spawn-time) causes. */
|
|
29
|
+
export const CWD_CHECK_CAUSES = ["missing", "not_toplevel"];
|
|
30
|
+
/** Claim attestation checks in M1 order (3 observe-only; 6, 9, 13 cut). `cwd` is the daemon's spawn-time check. */
|
|
31
|
+
export const ATTESTATION_CHECKS_M1 = [
|
|
32
|
+
"1",
|
|
33
|
+
"2",
|
|
34
|
+
"3",
|
|
35
|
+
"4",
|
|
36
|
+
"5",
|
|
37
|
+
"7",
|
|
38
|
+
"8",
|
|
39
|
+
"10",
|
|
40
|
+
"11",
|
|
41
|
+
"12",
|
|
42
|
+
"cwd",
|
|
43
|
+
];
|
|
44
|
+
export const AGENT_CONTAINED_STATUSES = ["paused", "killed"];
|
|
45
|
+
/**
|
|
46
|
+
* Every durable code reachable in M1. `goal_contract_enforce_refused` is the existing gateway 429
|
|
47
|
+
* (gateway/src/index.ts enforce path), listed because durable fixes ride on it (G2 budget variants).
|
|
48
|
+
* Cut codes (durable_wrong_cell 421, durable_host_unattended_off 423, durable_goal_unsealed) are
|
|
49
|
+
* deliberately absent: an M1 build that emits one fails the code-closure check.
|
|
50
|
+
*/
|
|
51
|
+
export const DURABLE_CODES = {
|
|
52
|
+
// ---- gateway admission (precedence order: admission.ts ADMISSION_PRECEDENCE) ----
|
|
53
|
+
durable_admission_unavailable: { status: 503, surfaces: ["gateway"], fields: [] },
|
|
54
|
+
durable_key_revoked: { status: 401, surfaces: ["gateway"], fields: [] },
|
|
55
|
+
durable_identity_mismatch: { status: 409, surfaces: ["gateway"], fields: [] },
|
|
56
|
+
durable_unlocked: { status: 410, surfaces: ["gateway"], fields: [] },
|
|
57
|
+
durable_session_ended: {
|
|
58
|
+
status: 410,
|
|
59
|
+
surfaces: ["gateway", "api"],
|
|
60
|
+
fields: ["state", "state_reason"],
|
|
61
|
+
},
|
|
62
|
+
durable_lease_fenced: { status: 409, surfaces: ["gateway", "api"], fields: [] },
|
|
63
|
+
durable_session_stopped: {
|
|
64
|
+
status: 423,
|
|
65
|
+
surfaces: ["gateway"],
|
|
66
|
+
fields: ["state", "state_reason"],
|
|
67
|
+
},
|
|
68
|
+
durable_guard_unavailable: { status: 503, surfaces: ["gateway"], fields: [] },
|
|
69
|
+
durable_unattended_unavailable: { status: 503, surfaces: ["gateway"], fields: [] },
|
|
70
|
+
/** The existing gateway enforce 429 (goal-contract.ts); durable adds only its fix lines. */
|
|
71
|
+
goal_contract_enforce_refused: { status: 429, surfaces: ["gateway"], fields: [] },
|
|
72
|
+
// ---- gateway credential routing (S1 choice: C06 OQ "control-route, /router and org-metering codes") ----
|
|
73
|
+
/** An mnm_ds_ key on a control route the arm did not run for, on /router (router-auth) or on org metering. */
|
|
74
|
+
durable_route_refused: { status: 403, surfaces: ["gateway"], fields: [] },
|
|
75
|
+
/**
|
|
76
|
+
* An executor (or bridge) key presented at any gateway entry point (model routes, control
|
|
77
|
+
* routes, /router, org metering: C04 claim "refused at every gateway entry point").
|
|
78
|
+
*/
|
|
79
|
+
durable_executor_key_refused: { status: 403, surfaces: ["gateway"], fields: [] },
|
|
80
|
+
// ---- credential and agent rules shared by gateway, api and cli ----
|
|
81
|
+
durable_only_agent: { status: 409, surfaces: ["gateway", "api", "cli"], fields: [] },
|
|
82
|
+
machine_principal_refused: { status: 403, surfaces: ["api"], fields: [] },
|
|
83
|
+
/** A device-step verb (unlock, budget raise, contained unpause) with an API-key-only owner credential (final F06). */
|
|
84
|
+
durable_session_login_required: { status: 403, surfaces: ["api", "cli"], fields: [] },
|
|
85
|
+
// ---- api owner verbs (owner-verbs.ts OWNER_VERB_PRECEDENCE) ----
|
|
86
|
+
durable_not_owner: { status: 403, surfaces: ["api"], fields: ["owner"] },
|
|
87
|
+
durable_agent_contained: { status: 409, surfaces: ["api"], fields: ["status"] },
|
|
88
|
+
durable_invalid_transition: {
|
|
89
|
+
status: 409,
|
|
90
|
+
surfaces: ["api"],
|
|
91
|
+
fields: ["from_state", "state_reason", "verb"],
|
|
92
|
+
},
|
|
93
|
+
durable_unsupported: { status: 422, surfaces: ["api"], fields: ["feature"] },
|
|
94
|
+
/** An own_lock body key outside LOCK_BODY_KEYS, or a malformed known field (ruling 33.24(1)); field null = not an object. */
|
|
95
|
+
durable_lock_body_invalid: { status: 422, surfaces: ["api"], fields: ["field"] },
|
|
96
|
+
/** A non-budget raise or loosening on amend (C07-R07); also a budget raise mixed with one. */
|
|
97
|
+
durable_amend_raise_refused: { status: 409, surfaces: ["api"], fields: ["field"] },
|
|
98
|
+
// ---- api lock preconditions (C02-R04, R05, R11, R22) ----
|
|
99
|
+
durable_lock_not_entitled: { status: 403, surfaces: ["api"], fields: [] },
|
|
100
|
+
durable_lock_mfa_required: { status: 403, surfaces: ["api"], fields: [] },
|
|
101
|
+
durable_lock_branch_unprotected: { status: 409, surfaces: ["api"], fields: ["refusals"] },
|
|
102
|
+
durable_lock_agent_shared: { status: 409, surfaces: ["api"], fields: ["reason"] },
|
|
103
|
+
durable_no_executor: { status: 409, surfaces: ["api"], fields: [] },
|
|
104
|
+
/** Retryable: a precondition source (IdP, GitHub, entitlement, schema probe, executor lookup) faulted. */
|
|
105
|
+
durable_precondition_unavailable: { status: 503, surfaces: ["api"], fields: ["retryable"] },
|
|
106
|
+
/** CLI-side lock refusal: no request is sent. */
|
|
107
|
+
durable_cwd_not_root: { status: null, surfaces: ["cli"], fields: ["cwd_kind"] },
|
|
108
|
+
// ---- api session registry (C01) ----
|
|
109
|
+
/** normalizeCellId(CELL_ID) is null at create: fail closed, no row. */
|
|
110
|
+
durable_cell_unmapped: { status: 503, surfaces: ["api"], fields: [] },
|
|
111
|
+
invalid_session_name: { status: 400, surfaces: ["api", "cli"], fields: [] },
|
|
112
|
+
session_name_in_use: { status: 409, surfaces: ["api", "cli"], fields: [] },
|
|
113
|
+
session_locked: { status: 409, surfaces: ["api", "cli"], fields: [] },
|
|
114
|
+
session_homed_elsewhere: { status: null, surfaces: ["cli"], fields: ["machine"] },
|
|
115
|
+
session_transcript_missing: { status: null, surfaces: ["cli"], fields: [] },
|
|
116
|
+
session_registry_unavailable: { status: null, surfaces: ["cli"], fields: [] },
|
|
117
|
+
session_resume_conflict: { status: null, surfaces: ["cli"], fields: [] },
|
|
118
|
+
session_goal_immutable: { status: null, surfaces: ["cli"], fields: [] },
|
|
119
|
+
// ---- api executor plane (C05) ----
|
|
120
|
+
durable_claim_unavailable: { status: 503, surfaces: ["api"], fields: ["cause"] },
|
|
121
|
+
durable_hello_late: { status: 409, surfaces: ["api"], fields: [] },
|
|
122
|
+
// Claim non-200 outcomes (rulings 24.22, 24.22.1), at CLAIM_OUTCOME_STATUS. lost_race's reason is
|
|
123
|
+
// a CLAIM_LOST_RACE_REASONS value; ineligible's reason a CLAIM_INELIGIBLE_REASONS value, with
|
|
124
|
+
// state_reason, check and state present per CLAIM_INELIGIBLE_DETAILS (claimIneligibleDetailsOk).
|
|
125
|
+
durable_claim_needs_key: { status: 409, surfaces: ["api"], fields: [] },
|
|
126
|
+
// org_lease_cap (ruling 34.05 (3)) adds the optional live and cap.
|
|
127
|
+
durable_claim_lost_race: { status: 409, surfaces: ["api"], fields: ["reason", "live", "cap"] },
|
|
128
|
+
// waiting (ruling 34.06 (3)) adds wait_reason.
|
|
129
|
+
durable_claim_ineligible: {
|
|
130
|
+
status: 403,
|
|
131
|
+
surfaces: ["api"],
|
|
132
|
+
fields: ["reason", "state_reason", "check", "state", "wait_reason"],
|
|
133
|
+
},
|
|
134
|
+
// The per-org claim rate limit (ruling 34.24): nothing written, no key minted. retry_after_s is
|
|
135
|
+
// the number of seconds to wait (claimRateLimitedDetailsOk).
|
|
136
|
+
durable_claim_rate_limited: { status: 429, surfaces: ["api"], fields: ["retry_after_s"] },
|
|
137
|
+
// ---- api journal (C10-R0 (i), (j), (k)) ----
|
|
138
|
+
/** Lost CAS race on (session_id, seq). */
|
|
139
|
+
durable_append_conflict: { status: 409, surfaces: ["api"], fields: ["tip_seq"] },
|
|
140
|
+
/** Same idempotency key, different content: always this one result (C10-R0 (j)). */
|
|
141
|
+
durable_idempotency_conflict: { status: 409, surfaces: ["api"], fields: ["seq"] },
|
|
142
|
+
durable_unknown_kind: { status: 422, surfaces: ["api"], fields: ["kind"] },
|
|
143
|
+
/** The caller's writer class may not append this kind (executor, gateway, api lists). */
|
|
144
|
+
durable_writer_refused: { status: 403, surfaces: ["api"], fields: ["kind"] },
|
|
145
|
+
// reason (erratum 34.06.3.1): a PARK_REFUSAL_REASONS value, only when kind is session.waiting.
|
|
146
|
+
durable_refs_invalid: { status: 422, surfaces: ["api"], fields: ["kind", "reason"] },
|
|
147
|
+
// ---- api device-step approval POST (device-step.ts APPROVAL_REFUSAL_ORDER; C16 OQ3) ----
|
|
148
|
+
durable_approval_no_session: { status: 401, surfaces: ["api"], fields: [] },
|
|
149
|
+
durable_approval_not_eligible: { status: 403, surfaces: ["api"], fields: [] },
|
|
150
|
+
durable_approval_aal_required: { status: 403, surfaces: ["api"], fields: [] },
|
|
151
|
+
durable_approval_step_up_stale: { status: 403, surfaces: ["api"], fields: [] },
|
|
152
|
+
durable_approval_requester_not_distinct: { status: 403, surfaces: ["api"], fields: [] },
|
|
153
|
+
durable_approval_expired: { status: 410, surfaces: ["api"], fields: [] },
|
|
154
|
+
durable_approval_consumed: { status: 409, surfaces: ["api"], fields: [] },
|
|
155
|
+
/** unlock refused at apply time because another locked session keeps the durable-only flag. */
|
|
156
|
+
durable_unlock_refused: { status: 409, surfaces: ["api"], fields: [] },
|
|
157
|
+
// ---- api executor enrollment start, POST ROUTES.exec_enroll (C04-R02, R03; wave-0 fix 3b) ----
|
|
158
|
+
// Names kept verbatim from C04-R03. A machine principal keeps 403 machine_principal_refused
|
|
159
|
+
// (C04-R02); a non-starter approver gets durable_approval_not_eligible (ruling 1.13). Device-poll
|
|
160
|
+
// errors are not codes here: see ENROLL_POLL_ERRORS.
|
|
161
|
+
/** The caller lacks the entitlement durable.locked. */
|
|
162
|
+
not_entitled: { status: 403, surfaces: ["api"], fields: [] },
|
|
163
|
+
/** The declared kind is not in durable.executors (M1 allows 'host' only). */
|
|
164
|
+
kind_not_allowed: { status: 403, surfaces: ["api"], fields: [] },
|
|
165
|
+
/** durable_schema_version() does not answer; retryable. */
|
|
166
|
+
schema_unavailable: { status: 503, surfaces: ["api"], fields: ["retryable"] },
|
|
167
|
+
// ---- gateway, Doors amendment (ruling 34.11) ----
|
|
168
|
+
/**
|
|
169
|
+
* An mnm_ds_ request whose x-mnemom-contract names another contract than the session's current
|
|
170
|
+
* charter version; refused before any upstream call, with no turn and no event.
|
|
171
|
+
*/
|
|
172
|
+
contract_mismatch: { status: 409, surfaces: ["gateway"], fields: ["expected_version"] },
|
|
173
|
+
// ---- api internal, charter by hash (ruling 33.32) ----
|
|
174
|
+
/**
|
|
175
|
+
* POST ROUTES.int_charter names an unknown session, a hash that is not one of its charter
|
|
176
|
+
* versions, or no charter at all (a malformed body). The gateway refuses admission on it.
|
|
177
|
+
*/
|
|
178
|
+
durable_charter_not_found: { status: 404, surfaces: ["api"], fields: [] },
|
|
179
|
+
};
|
|
180
|
+
export function isDurableCode(v) {
|
|
181
|
+
return typeof v === "string" && Object.prototype.hasOwnProperty.call(DURABLE_CODES, v);
|
|
182
|
+
}
|
|
183
|
+
export function statusOf(code) {
|
|
184
|
+
return DURABLE_CODES[code].status;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Build the error envelope for `code`, as buildErrorBody does: `details` only when given. Throws
|
|
188
|
+
* when details carries a field outside `fix` and DURABLE_CODES[code].fields, or a non-string fix.
|
|
189
|
+
*/
|
|
190
|
+
export function durableErrorBody(code, message, details) {
|
|
191
|
+
if (details === undefined)
|
|
192
|
+
return { error: { code, message } };
|
|
193
|
+
const allowed = ["fix", ...DURABLE_CODES[code].fields];
|
|
194
|
+
for (const k of Object.keys(details)) {
|
|
195
|
+
if (!allowed.includes(k))
|
|
196
|
+
throw new Error(`${code}: details field ${k} is not one of ${allowed.join(", ")}`);
|
|
197
|
+
}
|
|
198
|
+
if (details.fix !== undefined && typeof details.fix !== "string")
|
|
199
|
+
throw new Error(`${code}: details.fix must be a string`);
|
|
200
|
+
return { error: { code, message, details } };
|
|
201
|
+
}
|
|
202
|
+
/** Gateway refusal codes reachable in M1 on an mnm_ds_ request (C19 durable_refusal value set, plus `none` and `unknown_key`). */
|
|
203
|
+
export const GATEWAY_REFUSAL_CODES = [
|
|
204
|
+
"durable_admission_unavailable",
|
|
205
|
+
"durable_key_revoked",
|
|
206
|
+
"durable_identity_mismatch",
|
|
207
|
+
"durable_unlocked",
|
|
208
|
+
"durable_session_ended",
|
|
209
|
+
"durable_lease_fenced",
|
|
210
|
+
"durable_session_stopped",
|
|
211
|
+
"durable_guard_unavailable",
|
|
212
|
+
"durable_unattended_unavailable",
|
|
213
|
+
"goal_contract_enforce_refused",
|
|
214
|
+
"durable_route_refused",
|
|
215
|
+
"durable_executor_key_refused",
|
|
216
|
+
/** Doors amendment (ruling 34.11): x-mnemom-contract names another contract. */
|
|
217
|
+
"contract_mismatch",
|
|
218
|
+
];
|
|
219
|
+
/**
|
|
220
|
+
* Retry rule (BACKBONE): every gateway durable refusal carries `x-should-retry: false`, except
|
|
221
|
+
* 503 durable_admission_unavailable on an attended chain, which carries no x-should-retry header
|
|
222
|
+
* (attended chains keep today's availability). Returns the header value, or null for "omit".
|
|
223
|
+
* durable_claim_unavailable belongs to the daemon backoff, not to this rule.
|
|
224
|
+
*/
|
|
225
|
+
export function shouldRetryHeader(code, attended) {
|
|
226
|
+
return code === "durable_admission_unavailable" && attended ? null : "false";
|
|
227
|
+
}
|
|
228
|
+
/** Codes named by the design but CUT from M1. No M1 build may emit them (code-closure check). */
|
|
229
|
+
export const CUT_CODES_M1 = [
|
|
230
|
+
"durable_wrong_cell",
|
|
231
|
+
"durable_host_unattended_off",
|
|
232
|
+
"durable_goal_unsealed",
|
|
233
|
+
"durable_arm_unavailable",
|
|
234
|
+
"durable_attestation_unavailable",
|
|
235
|
+
];
|
|
236
|
+
/** Claim outcomes (design §4.3 plus S1 `unavailable`), the value set of `durable_claim_outcome`. */
|
|
237
|
+
export const CLAIM_OUTCOMES = [
|
|
238
|
+
"acquired",
|
|
239
|
+
"reclaimed",
|
|
240
|
+
"epoch_bump",
|
|
241
|
+
"needs_key",
|
|
242
|
+
"lost_race",
|
|
243
|
+
"ineligible",
|
|
244
|
+
"unavailable",
|
|
245
|
+
"rate_limited",
|
|
246
|
+
];
|
|
247
|
+
/**
|
|
248
|
+
* HTTP status of each claim outcome at POST /v1/executor/sessions/{id}/claim (C05 OQ0 proposal,
|
|
249
|
+
* frozen). A foreign or unknown session is the existing 404 before any outcome is computed.
|
|
250
|
+
*/
|
|
251
|
+
export const CLAIM_OUTCOME_STATUS = {
|
|
252
|
+
acquired: 200,
|
|
253
|
+
reclaimed: 200,
|
|
254
|
+
epoch_bump: 200,
|
|
255
|
+
needs_key: 409,
|
|
256
|
+
lost_race: 409,
|
|
257
|
+
ineligible: 403,
|
|
258
|
+
unavailable: 503,
|
|
259
|
+
rate_limited: 429,
|
|
260
|
+
};
|
|
261
|
+
/** durable_claim_lost_race details.reason: A1 durable_claim_lease step 2 and step 4 (24.22.1). */
|
|
262
|
+
export const CLAIM_LOST_RACE_REASONS = ["stale_tokens", "lease_live", "org_lease_cap"];
|
|
263
|
+
/** durable_claim_ineligible details.reason: every value A1 durable_claim_lease returns (24.22.1). */
|
|
264
|
+
export const CLAIM_INELIGIBLE_REASONS = [
|
|
265
|
+
"bad_nonce",
|
|
266
|
+
"bad_attest_failure",
|
|
267
|
+
"not_found",
|
|
268
|
+
"not_locked",
|
|
269
|
+
"not_home",
|
|
270
|
+
"not_owner",
|
|
271
|
+
"executor_revoked",
|
|
272
|
+
"executor_breakglass",
|
|
273
|
+
"terminal",
|
|
274
|
+
"expired",
|
|
275
|
+
"cell_unmapped",
|
|
276
|
+
"agent_killed",
|
|
277
|
+
"paused",
|
|
278
|
+
"agent_contained",
|
|
279
|
+
"suspended",
|
|
280
|
+
"profile",
|
|
281
|
+
"respawn_failed",
|
|
282
|
+
"attestation_failed",
|
|
283
|
+
"identity_mismatch",
|
|
284
|
+
"budget_reached",
|
|
285
|
+
"grant_expired",
|
|
286
|
+
// ---- Doors amendment ----
|
|
287
|
+
/** A pool session claimed by an executor that is not an org-scope executor of its org (34.03 (2)). */
|
|
288
|
+
"not_pool_member",
|
|
289
|
+
/** wait_reason is one of PARKED_ONLY_WAIT_REASONS (34.06 (3)). */
|
|
290
|
+
"waiting",
|
|
291
|
+
];
|
|
292
|
+
/**
|
|
293
|
+
* What a durable_claim_ineligible refusal carries beside reason, per reason (24.22.1). A field not
|
|
294
|
+
* named is absent. state_reason: `paused` / `suspended` = the row's existing state_reason for that
|
|
295
|
+
* state; `reason` = equal to reason (a suspension the claim writes); `agent_contained` = that
|
|
296
|
+
* literal. check: an ATTESTATION_CHECKS_M1 value, on an attestation-driven suspension the claim
|
|
297
|
+
* writes ('4' for grant_expired). state: a TERMINAL_STATES value, for terminal only. wait_reason: a
|
|
298
|
+
* PARKED_ONLY_WAIT_REASONS value, for waiting only (ruling 34.06 (3)).
|
|
299
|
+
*/
|
|
300
|
+
export const CLAIM_INELIGIBLE_DETAILS = Object.freeze({
|
|
301
|
+
bad_nonce: {},
|
|
302
|
+
bad_attest_failure: {},
|
|
303
|
+
not_found: {},
|
|
304
|
+
not_locked: {},
|
|
305
|
+
not_home: {},
|
|
306
|
+
not_owner: {},
|
|
307
|
+
executor_revoked: {},
|
|
308
|
+
executor_breakglass: {},
|
|
309
|
+
terminal: { state: "terminal_state" },
|
|
310
|
+
expired: {},
|
|
311
|
+
cell_unmapped: {},
|
|
312
|
+
agent_killed: {},
|
|
313
|
+
paused: { state_reason: "paused" },
|
|
314
|
+
agent_contained: { state_reason: "agent_contained" },
|
|
315
|
+
suspended: { state_reason: "suspended" },
|
|
316
|
+
profile: {},
|
|
317
|
+
respawn_failed: { state_reason: "reason" },
|
|
318
|
+
attestation_failed: { state_reason: "reason", check: "attestation_check" },
|
|
319
|
+
identity_mismatch: { state_reason: "reason", check: "attestation_check" },
|
|
320
|
+
budget_reached: { state_reason: "reason", check: "attestation_check" },
|
|
321
|
+
grant_expired: { state_reason: "reason", check: "attestation_check" },
|
|
322
|
+
not_pool_member: {},
|
|
323
|
+
waiting: { wait_reason: "parked_only" },
|
|
324
|
+
});
|
|
325
|
+
/**
|
|
326
|
+
* durable_claim_lost_race's details: a CLAIM_LOST_RACE_REASONS reason, an optional fix, and live and
|
|
327
|
+
* cap (non-negative and positive integers) both present exactly when the reason is org_lease_cap
|
|
328
|
+
* (ruling 34.05 (3)).
|
|
329
|
+
*/
|
|
330
|
+
export function claimLostRaceDetailsOk(details) {
|
|
331
|
+
if (Object.keys(details).some((k) => !["fix", ...DURABLE_CODES.durable_claim_lost_race.fields].includes(k)))
|
|
332
|
+
return false;
|
|
333
|
+
if (!CLAIM_LOST_RACE_REASONS.includes(details.reason))
|
|
334
|
+
return false;
|
|
335
|
+
if (details.reason !== "org_lease_cap")
|
|
336
|
+
return !("live" in details) && !("cap" in details);
|
|
337
|
+
return (Number.isInteger(details.live) &&
|
|
338
|
+
details.live >= 0 &&
|
|
339
|
+
Number.isInteger(details.cap) &&
|
|
340
|
+
details.cap >= 1);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* durable_claim_rate_limited's details (ruling 34.24): retry_after_s, a non-negative finite number
|
|
344
|
+
* of seconds, required; an optional fix; nothing else.
|
|
345
|
+
*/
|
|
346
|
+
export function claimRateLimitedDetailsOk(details) {
|
|
347
|
+
if (Object.keys(details).some((k) => !["fix", ...DURABLE_CODES.durable_claim_rate_limited.fields].includes(k)))
|
|
348
|
+
return false;
|
|
349
|
+
const t = details.retry_after_s;
|
|
350
|
+
return typeof t === "number" && Number.isFinite(t) && t >= 0;
|
|
351
|
+
}
|
|
352
|
+
/** durable_claim_ineligible's details against CLAIM_INELIGIBLE_DETAILS; an optional fix; nothing else. */
|
|
353
|
+
export function claimIneligibleDetailsOk(details) {
|
|
354
|
+
if (Object.keys(details).some((k) => !["fix", ...DURABLE_CODES.durable_claim_ineligible.fields].includes(k)))
|
|
355
|
+
return false;
|
|
356
|
+
const reason = details.reason;
|
|
357
|
+
if (!CLAIM_INELIGIBLE_REASONS.includes(reason))
|
|
358
|
+
return false;
|
|
359
|
+
const rule = CLAIM_INELIGIBLE_DETAILS[reason];
|
|
360
|
+
for (const k of ["state_reason", "check", "state", "wait_reason"])
|
|
361
|
+
if (k in details !== k in rule)
|
|
362
|
+
return false;
|
|
363
|
+
switch (rule.state_reason) {
|
|
364
|
+
case "paused":
|
|
365
|
+
if (!STATE_REASONS.paused.includes(details.state_reason))
|
|
366
|
+
return false;
|
|
367
|
+
break;
|
|
368
|
+
case "suspended":
|
|
369
|
+
if (!STATE_REASONS.suspended.includes(details.state_reason))
|
|
370
|
+
return false;
|
|
371
|
+
break;
|
|
372
|
+
case "reason":
|
|
373
|
+
if (details.state_reason !== reason)
|
|
374
|
+
return false;
|
|
375
|
+
break;
|
|
376
|
+
case "agent_contained":
|
|
377
|
+
if (details.state_reason !== "agent_contained")
|
|
378
|
+
return false;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
if (rule.check !== undefined &&
|
|
382
|
+
!ATTESTATION_CHECKS_M1.includes(details.check))
|
|
383
|
+
return false;
|
|
384
|
+
if (rule.state !== undefined && !TERMINAL_STATES.includes(details.state))
|
|
385
|
+
return false;
|
|
386
|
+
if (rule.wait_reason !== undefined &&
|
|
387
|
+
!PARKED_ONLY_WAIT_REASONS.includes(details.wait_reason))
|
|
388
|
+
return false;
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* durable_refs_invalid details.reason for a release whose wait cannot park (rulings 34.06.3,
|
|
393
|
+
* 34.06.3.1): the named approval is not open or is past expires_at, belongs to another session, or
|
|
394
|
+
* has the wrong subject, or wait_ref is not the canonical WAIT_REF_KEYS text for its reason.
|
|
395
|
+
*/
|
|
396
|
+
export const PARK_REFUSAL_REASONS = [
|
|
397
|
+
"approval_not_open",
|
|
398
|
+
"approval_wrong_session",
|
|
399
|
+
"approval_wrong_subject",
|
|
400
|
+
"wait_ref_shape",
|
|
401
|
+
];
|
|
402
|
+
/**
|
|
403
|
+
* durable_refs_invalid's details: a string kind, an optional fix, and an optional reason that is
|
|
404
|
+
* a PARK_REFUSAL_REASONS value and may appear only when kind is session.waiting (34.06.3.1).
|
|
405
|
+
*/
|
|
406
|
+
export function refsInvalidDetailsOk(details) {
|
|
407
|
+
if (Object.keys(details).some((k) => !["fix", ...DURABLE_CODES.durable_refs_invalid.fields].includes(k)))
|
|
408
|
+
return false;
|
|
409
|
+
if (typeof details.kind !== "string")
|
|
410
|
+
return false;
|
|
411
|
+
if (!("reason" in details))
|
|
412
|
+
return true;
|
|
413
|
+
return (details.kind === "session.waiting" &&
|
|
414
|
+
PARK_REFUSAL_REASONS.includes(details.reason));
|
|
415
|
+
}
|
|
416
|
+
/** Reasons a heartbeat entry answers extended=false (C05 OQ0; the per-session batched array). */
|
|
417
|
+
export const HEARTBEAT_REASONS = [
|
|
418
|
+
"extended",
|
|
419
|
+
"revived",
|
|
420
|
+
"fenced",
|
|
421
|
+
"not_hello_spawn",
|
|
422
|
+
"not_revivable",
|
|
423
|
+
"contained",
|
|
424
|
+
"terminal",
|
|
425
|
+
// ---- Doors amendment ----
|
|
426
|
+
/** wait_reason is set: never revived, the wait kept, the rest of the batch unaffected (34.06.4). */
|
|
427
|
+
"waiting",
|
|
428
|
+
];
|
|
429
|
+
/**
|
|
430
|
+
* The heartbeat wire shape (ruling 24.15; A1 durable_heartbeat). The request names each session as
|
|
431
|
+
* {session_id, epoch, spawn_id}; the response body is {results: [...]}, one entry per session,
|
|
432
|
+
* {session_id, extended, reason, lease_expires_at?}, lease_expires_at present exactly when extended.
|
|
433
|
+
* Entry order is NOT promised (A1 answers in session_id order): match entries by session_id.
|
|
434
|
+
*/
|
|
435
|
+
export const HEARTBEAT_ENTRY_FIELDS = ["session_id", "epoch", "spawn_id"];
|
|
436
|
+
export const HEARTBEAT_RESULT_FIELDS = [
|
|
437
|
+
"session_id",
|
|
438
|
+
"extended",
|
|
439
|
+
"reason",
|
|
440
|
+
"lease_expires_at",
|
|
441
|
+
];
|
|
442
|
+
/** One response entry: the frozen keys only, a uuid session_id, a HEARTBEAT_REASONS reason. */
|
|
443
|
+
export function heartbeatResultOk(v) {
|
|
444
|
+
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
445
|
+
return false;
|
|
446
|
+
const o = v;
|
|
447
|
+
if (Object.keys(o).some((k) => !HEARTBEAT_RESULT_FIELDS.includes(k)))
|
|
448
|
+
return false;
|
|
449
|
+
if (!fieldOk({ type: "uuid", nullable: false }, o.session_id))
|
|
450
|
+
return false;
|
|
451
|
+
if (typeof o.extended !== "boolean")
|
|
452
|
+
return false;
|
|
453
|
+
if (!fieldOk({ type: "enum", nullable: false, values: HEARTBEAT_REASONS }, o.reason))
|
|
454
|
+
return false;
|
|
455
|
+
// a waiting session is never extended (34.06.4): reason waiting only answers extended false
|
|
456
|
+
if (o.extended && o.reason === "waiting")
|
|
457
|
+
return false;
|
|
458
|
+
return o.extended
|
|
459
|
+
? fieldOk({ type: "timestamp", nullable: false }, o.lease_expires_at)
|
|
460
|
+
: !("lease_expires_at" in o);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The enroll poll's errors (POST ROUTES.exec_enroll_poll), in the RFC 8628 section 3.5 poll
|
|
464
|
+
* vocabulary plus `already_consumed` (wave-0 fix 3b). Each answers HTTP ENROLL_POLL_ERROR_STATUS
|
|
465
|
+
* with body {error: <value>}; they are not DURABLE_CODES. The CLI turns already_consumed into a
|
|
466
|
+
* non-zero exit naming `mnemom agent host install`.
|
|
467
|
+
*/
|
|
468
|
+
export const ENROLL_POLL_ERRORS = [
|
|
469
|
+
"authorization_pending",
|
|
470
|
+
"slow_down",
|
|
471
|
+
"access_denied",
|
|
472
|
+
"expired_token",
|
|
473
|
+
"already_consumed",
|
|
474
|
+
];
|
|
475
|
+
export const ENROLL_POLL_ERROR_STATUS = 400;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every frozen durable constant (BACKBONE "Pieces / S1", amendments 33-50). A spec or piece cites
|
|
3
|
+
* these by name and never restates a different value. The values the backbone left to "the S1
|
|
4
|
+
* freeze record" are chosen here; each carries its reason. `freeze-record.ts` copies them into
|
|
5
|
+
* the JSON record the eval runner reads as `$S1.<NAME>`.
|
|
6
|
+
*/
|
|
7
|
+
/** The contract version of this package. Any change to FREEZE.json bumps it. */
|
|
8
|
+
export declare const DURABLE_CONTRACT_VERSION = "1.0.0";
|
|
9
|
+
/**
|
|
10
|
+
* `durable_schema_version()` must return exactly this. A mismatch makes the entitlement `durable`
|
|
11
|
+
* field absent and a claim answers 503 durable_claim_unavailable {cause:"schema"} (A3).
|
|
12
|
+
*/
|
|
13
|
+
export declare const DURABLE_SCHEMA_VERSION = 1;
|
|
14
|
+
/** durable_cell_state.lease_seconds default, CHECK LEASE_SECONDS_MIN..LEASE_SECONDS_MAX. */
|
|
15
|
+
export declare const LEASE_SECONDS_DEFAULT = 90;
|
|
16
|
+
export declare const LEASE_SECONDS_MIN = 5;
|
|
17
|
+
export declare const LEASE_SECONDS_MAX = 90;
|
|
18
|
+
/** durable_cell_state.resume_reset_seconds default, CHECK RESUME_RESET_SECONDS_MIN..MAX. */
|
|
19
|
+
export declare const RESUME_RESET_SECONDS_DEFAULT = 600;
|
|
20
|
+
export declare const RESUME_RESET_SECONDS_MIN = 5;
|
|
21
|
+
export declare const RESUME_RESET_SECONDS_MAX = 600;
|
|
22
|
+
/** Heartbeat period = lease_seconds / HEARTBEAT_DIVISOR (30 s at 90, 2 s at 6). */
|
|
23
|
+
export declare const HEARTBEAT_DIVISOR = 3;
|
|
24
|
+
/** resume_failures at which a session goes to suspended(respawn_failed). */
|
|
25
|
+
export declare const RESPAWN_FAILURES_SUSPEND_AT = 3;
|
|
26
|
+
/** Seats the daemon respawns at once. */
|
|
27
|
+
export declare const RESPAWN_CONCURRENCY = 4;
|
|
28
|
+
/** resolve_durable_session_key touches last_used_at only when NULL or older than this (DB clock). */
|
|
29
|
+
export declare const LEASE_KEY_TOUCH_SECONDS = 60;
|
|
30
|
+
/** M1 has no stale serve: every resolver fault is 503 durable_admission_unavailable (I20). */
|
|
31
|
+
export declare const STALE_SERVE_M1: false;
|
|
32
|
+
/** M1 honours DURABLE_ADMIT, but only for the exact bytes NOFENCE_ADMIT_VALUE (r3 I01). */
|
|
33
|
+
export declare const NOFENCE_M1: true;
|
|
34
|
+
export declare const NOFENCE_ADMIT_VALUE = "nofence";
|
|
35
|
+
/** Upper bound for one resolver RPC; past it the gateway answers 503 (C06-R07 "timeout T"). */
|
|
36
|
+
export declare const RESOLVER_TIMEOUT_MS = 2000;
|
|
37
|
+
/** Claim-time arm probe (GET /internal/durable/arm at the home cell) must answer within this. */
|
|
38
|
+
export declare const ARM_PROBE_TIMEOUT_MS = 2000;
|
|
39
|
+
/** A parseable arm probe answer is cached at most this long. */
|
|
40
|
+
export declare const ARM_PROBE_TTL_S = 10;
|
|
41
|
+
/** Check 12: a `protected` answer is cached per (repo, branch) this long. */
|
|
42
|
+
export declare const PROTECTION_CACHE_S = 300;
|
|
43
|
+
/** Executor grant: renewal sets grant_expires_at = now() + GRANT_TTL_S. */
|
|
44
|
+
export declare const GRANT_TTL_S: number;
|
|
45
|
+
/** sessions, show and host status warn in the last GRANT_WARNING_S of the grant. */
|
|
46
|
+
export declare const GRANT_WARNING_S: number;
|
|
47
|
+
/** Clean seat exits (exit 0 after an accepted hello) beyond CLEAN_EXIT_MAX in the window count as failures. */
|
|
48
|
+
export declare const CLEAN_EXIT_MAX = 3;
|
|
49
|
+
export declare const CLEAN_EXIT_WINDOW_S = 600;
|
|
50
|
+
/** The daemon polls GET /v1/executor/sessions every EXECUTOR_POLL_S. */
|
|
51
|
+
export declare const EXECUTOR_POLL_S = 10;
|
|
52
|
+
/** An executor whose last_seen_at is older than this is not live. */
|
|
53
|
+
export declare const EXECUTOR_LIVE_S: number;
|
|
54
|
+
/** Claim backoff on 503 durable_claim_unavailable: CLAIM_BACKOFF_BASE_S doubling to CLAIM_BACKOFF_MAX_S. */
|
|
55
|
+
export declare const CLAIM_BACKOFF_BASE_S = 2;
|
|
56
|
+
export declare const CLAIM_BACKOFF_MAX_S = 60;
|
|
57
|
+
/** Each backoff delay is stretched by a factor in [1, 1 + CLAIM_BACKOFF_JITTER). */
|
|
58
|
+
export declare const CLAIM_BACKOFF_JITTER = 0.2;
|
|
59
|
+
/** host status prints the guard fix after more than this many consecutive `guard` unavailable claims. */
|
|
60
|
+
export declare const CLAIM_UNAVAILABLE_SURFACE_N = 5;
|
|
61
|
+
/** SIGTERM to SIGKILL grace when done/kill stops a local tracked claude (final F04). */
|
|
62
|
+
export declare const TRACKED_STOP_GRACE_S = 5;
|
|
63
|
+
/**
|
|
64
|
+
* Upstream attempts one typed turn may produce on a non-retryable refusal (C13-R14). Expected 1;
|
|
65
|
+
* PROVISIONAL until the day-1 spike with claude 2.1.285 records the real number.
|
|
66
|
+
*/
|
|
67
|
+
export declare const SEAT_MAX_ATTEMPTS_NONRETRY = 1;
|
|
68
|
+
/** A synced main request waits up to TURN_WAIT_MS for its prompt (= cli/src/turn-origin.mjs WAIT_MS on origin/main). */
|
|
69
|
+
export declare const TURN_WAIT_MS = 500;
|
|
70
|
+
/** x-mnemom-turn limits, equal to gateway/src/goal-turn-claims.ts. */
|
|
71
|
+
export declare const TURN_HEADER_MAX_LEN = 8192;
|
|
72
|
+
export declare const TURN_ENTRIES_MAX = 32;
|
|
73
|
+
/** One global row cap across all categories per run. */
|
|
74
|
+
export declare const SWEEP_MAX_ROWS = 200;
|
|
75
|
+
/** Rows per batch; SWEEP_BATCH_SIZE < SWEEP_MAX_ROWS. */
|
|
76
|
+
export declare const SWEEP_BATCH_SIZE = 50;
|
|
77
|
+
/** Time budget T per run. */
|
|
78
|
+
export declare const SWEEP_TIME_BUDGET_MS = 10000;
|
|
79
|
+
export declare const SWEEP_CRON = "*/5 * * * *";
|
|
80
|
+
/**
|
|
81
|
+
* The per-session budget limit in USD, code-fixed and conservative (owner Q2). The single source
|
|
82
|
+
* for the amend bound, the 422 and the gateway 429; durable_org_policy.limits is seeded from it
|
|
83
|
+
* and not read in M1 (parity test: seed == constant).
|
|
84
|
+
*/
|
|
85
|
+
export declare const PER_SESSION_BUDGET_LIMIT_USD = 20;
|
|
86
|
+
/** durable_org_policy.limits seed, built from the constant above. */
|
|
87
|
+
export declare const ORG_POLICY_LIMITS_SEED: Readonly<{
|
|
88
|
+
per_session_budget_usd: 20;
|
|
89
|
+
}>;
|
|
90
|
+
/** The API's frozen contract statement limit (= gateway goal-contract STATEMENT_MAX). */
|
|
91
|
+
export declare const CONTRACT_STATEMENT_MAX_CHARS = 4000;
|
|
92
|
+
/** canonicalJson of the whole contract plaintext (= gateway goal-contract CONTRACT_JSON_MAX). */
|
|
93
|
+
export declare const CONTRACT_JSON_MAX_BYTES = 8192;
|
|
94
|
+
/** agent_session_events.detail is server-generated and at most this many characters. */
|
|
95
|
+
export declare const EVENT_DETAIL_MAX_CHARS = 280;
|
|
96
|
+
/** contract_ciphertext is purged this long after the session ends. */
|
|
97
|
+
export declare const CONTRACT_PURGE_AFTER_S: number;
|
|
98
|
+
/** owner_mutation needs aal2 and a step-up no older than this. */
|
|
99
|
+
export declare const DEVICE_STEP_FRESHNESS_S = 300;
|
|
100
|
+
/**
|
|
101
|
+
* The cookie SessionBlob key holding the step-up time, integer unix seconds, optional (ruling 27;
|
|
102
|
+
* C16-R10). Fresh when 0 <= now - su <= DEVICE_STEP_FRESHNESS_S; an absent or future su is stale.
|
|
103
|
+
* Separate from `ia`: a step-up renews freshness without extending the session's lifetime.
|
|
104
|
+
*/
|
|
105
|
+
export declare const STEP_UP_BLOB_FIELD = "su";
|
|
106
|
+
/** An owner_mutation approval expires with its device code (= api DEVICE_CODE_TTL_SECONDS). */
|
|
107
|
+
export declare const OWNER_MUTATION_APPROVAL_TTL_S: number;
|
|
108
|
+
/** The CLI polls the device grant this often (= api DEVICE_POLL_INTERVAL_SECONDS). */
|
|
109
|
+
export declare const DEVICE_POLL_INTERVAL_S = 5;
|
|
110
|
+
/** The laptop risk-line text version (fixlines.ts RISK_LINE_TEXT). Bump with any text change. */
|
|
111
|
+
export declare const RISK_LINE_VERSION = 1;
|
|
112
|
+
/** RISK_LINE_VERSION as the decimal text the A1 column, the page marker and the enrollment approval subject carry (ruling 32.30). */
|
|
113
|
+
export declare const RISK_LINE_VERSION_TEXT: string;
|
|
114
|
+
/** The --settings / --mcp-config renderer version recorded in attestation.passed (spec.ts). */
|
|
115
|
+
export declare const RENDERER_VERSION = 1;
|
|
116
|
+
/** The plugin dir-hash recipe version (spec.ts pluginDirHash). */
|
|
117
|
+
export declare const PLUGIN_HASH_RECIPE_VERSION = 1;
|
|
118
|
+
/** The journal preimage version (events.ts EVENT_PREIMAGE_FIELDS). */
|
|
119
|
+
export declare const EVENT_PREIMAGE_VERSION = 1;
|
|
120
|
+
/**
|
|
121
|
+
* L_spawn, the lease every real-claude case runs at (20..90), set by ruling 34.17 (calibration):
|
|
122
|
+
* max(20, ceil(3 x p100 claim-to-hello)) s, capped at 90, with p100 the maximum over the clean
|
|
123
|
+
* calibration runs (2.616 s, run42), so max(20, 8) = 20. Re-derived only by a new calibration ruling.
|
|
124
|
+
*/
|
|
125
|
+
export declare const L_SPAWN: number | null;
|
|
126
|
+
export declare const L_SPAWN_MIN = 20;
|
|
127
|
+
export declare const L_SPAWN_MAX = 90;
|
|
128
|
+
/**
|
|
129
|
+
* T_hello, the calibrated per-seat spawn-to-hello time in seconds (C12-R31 recovery bound), set by
|
|
130
|
+
* the same ruling 34.17 calibration as L_SPAWN: p100 claim-to-hello at 4
|
|
131
|
+
* concurrent respawns, the maximum over the clean runs (run41 1.873, run42 2.616).
|
|
132
|
+
*/
|
|
133
|
+
export declare const T_HELLO_S: number | null;
|
|
134
|
+
/**
|
|
135
|
+
* The first-party public OAuth client an owner_mutation device code is bound to (C16-R01; wave-0
|
|
136
|
+
* fix ruling 1.12). A1 seeds it; every 202 device-step body returns it as client_id; the generic
|
|
137
|
+
* /v1/oauth/device_authorization refuses it for every scope (C16-A-032). The CLI's login client is
|
|
138
|
+
* NOT frozen: it is issued by RFC 7591 dynamic registration.
|
|
139
|
+
*/
|
|
140
|
+
export declare const OWNER_MUTATION_CLIENT_ID = "mnemom-durable-owner-mutation";
|
|
141
|
+
/** ATTACH_WAIT_S = EXECUTOR_POLL_S + lease_seconds (BACKBONE). Throws outside the lease CHECK range. */
|
|
142
|
+
export declare function attachWaitSeconds(leaseSeconds: number): number;
|
|
143
|
+
/** ATTACH_WAIT_S at the default 90 s lease. */
|
|
144
|
+
export declare const ATTACH_WAIT_S: number;
|
|
145
|
+
/** Heartbeat period in seconds for a lease, derived from the server's lease. */
|
|
146
|
+
export declare function heartbeatSeconds(leaseSeconds: number): number;
|
|
147
|
+
/**
|
|
148
|
+
* Delay before claim attempt `attempt` (1-based) after consecutive 503 durable_claim_unavailable
|
|
149
|
+
* answers: CLAIM_BACKOFF_BASE_S * 2^(attempt-1), capped at CLAIM_BACKOFF_MAX_S, stretched by
|
|
150
|
+
* (1 + CLAIM_BACKOFF_JITTER * r) where r in [0, 1) is the caller's random draw. So no gap is under
|
|
151
|
+
* 2 s and none is over 60 s x (1 + CLAIM_BACKOFF_JITTER) (C12-R30).
|
|
152
|
+
*/
|
|
153
|
+
export declare function claimBackoffMs(attempt: number, r: number): number;
|