@byollm/protocol 0.1.0-alpha.62 → 0.1.0-alpha.63

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  > [!WARNING]
2
- > **Alpha (`0.1.0-alpha.62`) — under active development. Don't use this yet.**
2
+ > **Alpha (`0.1.0-alpha.63`) — under active development. Don't use this yet.**
3
3
  >
4
4
  > Install it deliberately: `npm install @byollm/protocol@alpha`.
5
5
  >
@@ -83,7 +83,7 @@
83
83
  > packages published and `@byollm/server` did not: a Sigstore
84
84
  > transparency-log 409 on its provenance attestation. The workflow's
85
85
  > "already published" guard correctly refuses to resume a partial publish,
86
- > so `0.1.0-alpha.62` is that release, whole.
86
+ > so `0.1.0-alpha.63` is that release, whole.
87
87
  >
88
88
  > If you run the Supabase adapter, `alpha.21` needs
89
89
  > `20260819010000_completed_by_lease_id.sql`: alpha.19 shipped §3.6's
package/dist/index.d.ts CHANGED
@@ -880,6 +880,16 @@ declare const SIZE_CLASSES: readonly ("small" | "medium" | "large" | "unbounded"
880
880
  * bucket survives compression and encoding changes that an exact count does
881
881
  * not.
882
882
  *
883
+ * **Two grains, on purpose — ratified 2026-08-28.** Metering a
884
+ * GB-denominated plan needs real totals, and this is deliberately not where
885
+ * they come from: exact bytes exist only as increment-only *monthly*
886
+ * aggregates, and no per-job byte figure is ever persisted anywhere. The
887
+ * record needs vagueness and the meter needs totals; neither borrows the
888
+ * other's grain, which is why the consent screen's "roughly how big" stays
889
+ * exactly true of everything retained about a job. If you are here because
890
+ * you need a number, the aggregate is the one to reach for — adding a byte
891
+ * count to this envelope would trade a promise for a convenience.
892
+ *
883
893
  * `unbounded` exists for streamed jobs, which have no size when they start.
884
894
  * It is reserved now rather than added later: byollm_009 §8.1 — adding a
885
895
  * field to a published envelope is the v2 break all over again.
@@ -891,6 +901,41 @@ declare const SizeClass: z.ZodEnum<{
891
901
  unbounded: "unbounded";
892
902
  }>;
893
903
  type SizeClass = z.infer<typeof SizeClass>;
904
+ /**
905
+ * The most one envelope may be, in bytes — ratified 2026-08-28.
906
+ *
907
+ * A **relay-memory safety rail**, not a plan feature: every tier has the same
908
+ * ceiling, and differentiating tiers on it would be selling a safety limit as
909
+ * a benefit. What it bounds is any single job, so no one message can make the
910
+ * relay hold an unbounded amount of somebody else's memory.
911
+ *
912
+ * ## It stores nothing, and that is the design
913
+ *
914
+ * Enforced at ingress by refusing before acceptance, in both directions. A
915
+ * ceiling on what the relay already has in hand needs no schema and no record:
916
+ * the size is known for the length of the check and then it is gone. This
917
+ * matters because the alternative — recording a size to enforce a limit
918
+ * against — is precisely the per-job byte figure the metering ruling exists to
919
+ * not have.
920
+ *
921
+ * ## Measured on the serialised envelope
922
+ *
923
+ * The same quantity the monthly rollup counts, deliberately. The relay stores
924
+ * the serialised envelope and the meter measures what it stored, so a cap on
925
+ * anything else — the ciphertext alone, the decoded length — would mean the
926
+ * limit and the bill disagreed about what a byte is, and a job could be small
927
+ * enough to accept and larger than it was charged as.
928
+ */
929
+ declare const MAX_ENVELOPE_BYTES: number;
930
+ /**
931
+ * How big an envelope is, by the one measure that counts it.
932
+ *
933
+ * `JSON.stringify` because that is what the store persists and therefore what
934
+ * the meter measures. Length in UTF-16 code units rather than encoded bytes:
935
+ * it is the same number the store's own `HSTRLEN` reports, and the point of
936
+ * this function is that one number answers both questions.
937
+ */
938
+ declare function envelopeBytes(envelope: unknown): number;
894
939
  /** Where the bucket boundaries sit, in characters of payload text. */
895
940
  declare const SIZE_CLASS_LIMITS: Readonly<{
896
941
  small: 4000;
@@ -2605,4 +2650,4 @@ declare const FetchResponse: z.ZodObject<{
2605
2650
  }, z.core.$strict>;
2606
2651
  type FetchResponse = z.infer<typeof FetchResponse>;
2607
2652
 
2608
- export { AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENCRYPTION_KEY_CONTEXT, ENDPOINTS, ENVELOPE_MAX_AGE_MS, ERROR_STATUS, type Endpoint, type EnvelopeContext, EnvelopeDirection, type EnvelopeFailure, FetchRequest, FetchResponse, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, type OpenResult, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, REFUSAL_MESSAGES, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedEnvelope, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkProtocolVersion, classifyCost, cryptoReady, declaredVersion, effectiveOfferScope, fingerprint, generateKeys, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, keyId, kindsOf, matchAudience, mustsVerifiedBy, open, payloadTextLength, provenanceFor, publicIdentityOf, resolveCost, seal, signGrant, signRequest, signSiteRequest, signSuccession, signWith, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, verifyGrant, verifyLink, verifyPublicIdentity, verifyRequest, verifySiteRequest, verifyWith, walkSuccession };
2653
+ export { AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENCRYPTION_KEY_CONTEXT, ENDPOINTS, ENVELOPE_MAX_AGE_MS, ERROR_STATUS, type Endpoint, type EnvelopeContext, EnvelopeDirection, type EnvelopeFailure, FetchRequest, FetchResponse, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_ENVELOPE_BYTES, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, type OpenResult, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, REFUSAL_MESSAGES, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedEnvelope, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkProtocolVersion, classifyCost, cryptoReady, declaredVersion, effectiveOfferScope, envelopeBytes, fingerprint, generateKeys, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, keyId, kindsOf, matchAudience, mustsVerifiedBy, open, payloadTextLength, provenanceFor, publicIdentityOf, resolveCost, seal, signGrant, signRequest, signSiteRequest, signSuccession, signWith, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, verifyGrant, verifyLink, verifyPublicIdentity, verifyRequest, verifySiteRequest, verifyWith, walkSuccession };
package/dist/index.js CHANGED
@@ -840,6 +840,11 @@ var DeliveredResult = z6.object({
840
840
  }).strict();
841
841
  var SizeClass = z6.enum(["small", "medium", "large", "unbounded"]);
842
842
  var SIZE_CLASSES = Object.freeze(SizeClass.options);
843
+ var MAX_ENVELOPE_BYTES = 10 * 1024 * 1024;
844
+ function envelopeBytes(envelope) {
845
+ const serialised = JSON.stringify(envelope);
846
+ return serialised === void 0 ? 0 : serialised.length;
847
+ }
843
848
  var SIZE_CLASS_LIMITS = Object.freeze({
844
849
  small: 4e3,
845
850
  medium: 64e3,
@@ -2333,6 +2338,7 @@ export {
2333
2338
  KindedPayload,
2334
2339
  Lease,
2335
2340
  MAX_CLOCK_SKEW_MS,
2341
+ MAX_ENVELOPE_BYTES,
2336
2342
  MAX_PURPOSES,
2337
2343
  MAX_SUCCESSION_CHAIN,
2338
2344
  MIN_PROTOCOL_VERSION,
@@ -2387,6 +2393,7 @@ export {
2387
2393
  cryptoReady,
2388
2394
  declaredVersion,
2389
2395
  effectiveOfferScope,
2396
+ envelopeBytes,
2390
2397
  fingerprint,
2391
2398
  generateKeys,
2392
2399
  grantStatement,