@silverprotocol/core 0.12.5 → 1.0.0-rc.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.
Files changed (54) hide show
  1. package/README.md +17 -9
  2. package/dist/agjson.d.ts +594 -594
  3. package/dist/agjson.d.ts.map +1 -1
  4. package/dist/agjson.js +25 -14
  5. package/dist/agjson.js.map +1 -1
  6. package/dist/atomic-push.d.ts +15 -9
  7. package/dist/atomic-push.d.ts.map +1 -1
  8. package/dist/atomic-push.js +16 -5
  9. package/dist/atomic-push.js.map +1 -1
  10. package/dist/copy-json.d.ts +27 -4
  11. package/dist/copy-json.d.ts.map +1 -1
  12. package/dist/copy-json.js +135 -1
  13. package/dist/copy-json.js.map +1 -1
  14. package/dist/depth.d.ts +0 -8
  15. package/dist/depth.d.ts.map +1 -1
  16. package/dist/depth.js +0 -9
  17. package/dist/depth.js.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/ingest.d.ts +2 -2
  23. package/dist/ingest.js +4 -4
  24. package/dist/ingest.js.map +1 -1
  25. package/dist/json-patch.d.ts.map +1 -1
  26. package/dist/json-patch.js +5 -1
  27. package/dist/json-patch.js.map +1 -1
  28. package/dist/persist.js.map +1 -1
  29. package/dist/record.js +2 -2
  30. package/dist/record.js.map +1 -1
  31. package/dist/reduce.d.ts +1 -1
  32. package/dist/reduce.d.ts.map +1 -1
  33. package/dist/reduce.js +277 -113
  34. package/dist/reduce.js.map +1 -1
  35. package/dist/stream-assembler.d.ts +6 -7
  36. package/dist/stream-assembler.d.ts.map +1 -1
  37. package/dist/stream-assembler.js +21 -18
  38. package/dist/stream-assembler.js.map +1 -1
  39. package/dist/wire.d.ts +21 -3
  40. package/dist/wire.d.ts.map +1 -1
  41. package/dist/wire.js +34 -5
  42. package/dist/wire.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/agjson.ts +36 -25
  45. package/src/atomic-push.ts +25 -13
  46. package/src/copy-json.ts +132 -4
  47. package/src/depth.ts +0 -10
  48. package/src/index.ts +1 -0
  49. package/src/ingest.ts +4 -4
  50. package/src/json-patch.ts +5 -1
  51. package/src/record.ts +2 -2
  52. package/src/reduce.ts +256 -112
  53. package/src/stream-assembler.ts +21 -18
  54. package/src/wire.ts +36 -6
package/dist/wire.js CHANGED
@@ -29,6 +29,22 @@ export const JSON_SAFE_MAX_DEPTH_MARK = "[MaxDepth]";
29
29
  * @beta
30
30
  */
31
31
  export const JSON_SAFE_MAX_DEPTH = 1000;
32
+ /**
33
+ * The levels an event's own members may add above a carried value that
34
+ * {@link toJsonValueSafe} capped at {@link JSON_SAFE_MAX_DEPTH}.
35
+ *
36
+ * @beta
37
+ */
38
+ export const AG_EVENT_DEPTH_ALLOWANCE = 16;
39
+ /**
40
+ * The deepest node an event may hold, counted from the event root: the root is
41
+ * at depth 0 and a node's depth is the number of containers above it.
42
+ * {@link JSON_SAFE_MAX_DEPTH} plus {@link AG_EVENT_DEPTH_ALLOWANCE}. A consuming
43
+ * ingest rejects a deeper event, and a reducer parks on one.
44
+ *
45
+ * @beta
46
+ */
47
+ export const AG_EVENT_MAX_DEPTH = JSON_SAFE_MAX_DEPTH + AG_EVENT_DEPTH_ALLOWANCE;
32
48
  /**
33
49
  * True when `v` is ALREADY a plain JSON value, i.e. exactly what a JSON
34
50
  * round-trip of it would produce: `null`, a string, a boolean, a finite
@@ -41,6 +57,15 @@ export const JSON_SAFE_MAX_DEPTH = 1000;
41
57
  * @beta
42
58
  */
43
59
  export function isJsonValue(v) {
60
+ return jsonWalk(v, false);
61
+ }
62
+ /** {@link isJsonValue} where every object also has the ordinary prototype
63
+ * (`Object.prototype`, or `Array.prototype` for an array): no null-prototype
64
+ * node. The fast path of {@link toJsonValueSafeWithIssues} uses it. */
65
+ function isOrdinaryJsonValue(v) {
66
+ return jsonWalk(v, true);
67
+ }
68
+ function jsonWalk(v, ordinaryOnly) {
44
69
  const ancestors = [];
45
70
  const walk = (x, depth) => {
46
71
  if (x === null)
@@ -62,6 +87,8 @@ export function isJsonValue(v) {
62
87
  ancestors.push(o);
63
88
  try {
64
89
  if (Array.isArray(o)) {
90
+ if (ordinaryOnly && Object.getPrototypeOf(o) !== Array.prototype)
91
+ return false;
65
92
  for (let i = 0; i < o.length; i++) {
66
93
  if (!(i in o) || !walk(o[i], depth + 1))
67
94
  return false;
@@ -69,7 +96,7 @@ export function isJsonValue(v) {
69
96
  return true;
70
97
  }
71
98
  const proto = Object.getPrototypeOf(o);
72
- if (proto !== Object.prototype && proto !== null)
99
+ if (proto !== Object.prototype && (ordinaryOnly || proto !== null))
73
100
  return false;
74
101
  if (typeof o.toJSON === "function")
75
102
  return false;
@@ -107,8 +134,10 @@ export function isJsonValue(v) {
107
134
  * Normalizer MUST NOT throw out of `push()` (SPEC.md §8.0). Keep
108
135
  * `JsonValue.parse` for validating data that is already JSON.
109
136
  *
110
- * Plain JSON input (see {@link isJsonValue}) is returned UNCHANGED, as the same
111
- * reference, with no copy. Anything else is rebuilt as a fresh value that
137
+ * Plain JSON input (see {@link isJsonValue}) whose every object has the
138
+ * ordinary prototype is returned UNCHANGED, as the same reference, with no
139
+ * copy. Anything else, a null-prototype node included, is rebuilt as a fresh
140
+ * value whose every object has the ordinary prototype and that
112
141
  * applies `JSON.stringify`'s own rules per node, so for JSON-able input the
113
142
  * result serializes identically to `toJsonValue(v)`:
114
143
  * - `toJSON` is honoured once per node, with the member key (a `Date` becomes
@@ -179,7 +208,7 @@ function isErrorObject(o) {
179
208
  * @beta
180
209
  */
181
210
  export function toJsonValueSafeWithIssues(v) {
182
- if (isJsonValue(v))
211
+ if (isOrdinaryJsonValue(v))
183
212
  return { value: v, issues: [] };
184
213
  const issues = [];
185
214
  const ancestors = [];
@@ -234,7 +263,7 @@ export function toJsonValueSafeWithIssues(v) {
234
263
  return JSON_SAFE_MAX_DEPTH_MARK;
235
264
  }
236
265
  if (isErrorObject(obj)) {
237
- // Deliberate extension beyond JSON (sp-main, 2026-09-24): an Error's
266
+ // Deliberate extension beyond JSON (ruled 2026-09-24): an Error's
238
267
  // `name` and `message` are not enumerable own data, so JSON drops them
239
268
  // and a live error part loses its text. Map it to {name, message, …own
240
269
  // enumerable props}, and NEVER `stack` (it holds local file paths).
package/dist/wire.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,MAAM,CAAC,GAAc,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,MAAM,CAAC,GAAc,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,YAAY,CAAC;AACrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAyBxC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,KAAa,EAAW,EAAE;QAClD,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC5B,QAAQ,OAAO,CAAC,EAAE,CAAC;YACjB,KAAK,QAAQ,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC;YACd,KAAK,QAAQ;gBACX,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC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GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@silverprotocol/core",
3
- "version": "0.12.5",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "AgJSON core — the typed schema (AgInput / AgEvent / AgMessage), the Normalizer interface, and the normative reduce().",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/agjson.ts CHANGED
@@ -121,7 +121,7 @@ export type AgSource = z.infer<typeof AgSource>;
121
121
 
122
122
  // Grounding-source payload union (spec §2/§4): the §4 `source` event's payload
123
123
  // union, extracted here so it can be reused verbatim by BOTH the event arm and
124
- // AgTurnRecord.sources[] — one definition, DRY, cast-free (audit M23).
124
+ // AgTurnRecord.sources[] — one definition, DRY, cast-free.
125
125
  export const AgSourcePayload = z.union([
126
126
  AgSource,
127
127
  z.object({ url: z.string(), title: z.string().optional() }),
@@ -532,7 +532,7 @@ export type AgBlock =
532
532
  toolMetadata?: AgMeta; // per-tool metadata bag (Vercel)
533
533
  dynamic?: boolean; // Vercel dynamic-vs-static tool distinction
534
534
  pendingInput?: AgPendingInput; // MCP MRTR carrier when outcome==="input_required"
535
- preliminary?: boolean; // set when the result is partial/kept-open (tool.done.more:true); cleared by the final tool.done (audit M20)
535
+ preliminary?: boolean; // set when the result is partial/kept-open (tool.done.more:true); cleared by the final tool.done
536
536
  isError?: boolean; // MCP-frozen field, kept verbatim (derived: outcome==="error")
537
537
  providerMetadata?: AgProviderMeta;
538
538
  annotations?: AgAnnotations;
@@ -555,7 +555,7 @@ const blockAnno = {
555
555
  };
556
556
 
557
557
  /**
558
- * The resource-link block (draft.5, pkg-05): MCP's ResourceLink members,
558
+ * The resource-link block (draft.5): MCP's ResourceLink members,
559
559
  * each optional beside the required `uri`. `size` is an integer, as ruled.
560
560
  * It is exported so a normalizer can check each native member against
561
561
  * core's own schema (`AgResourceLinkBlock.shape.<member>.safeParse(v)`), and
@@ -671,7 +671,7 @@ export const AgBlock: z.ZodType<AgBlock> = z.lazy(() =>
671
671
  // (HITL) arm: the turn parks on one or more asks; `result` MAY accompany a pause
672
672
  // (a partial value emitted before parking). `{type:"aborted"}` is turn.abort's
673
673
  // dedicated marker (symmetric with the error arm) — taskState is verbatim-A2A
674
- // only and is NEVER reducer-invented (audit M29).
674
+ // only and is NEVER reducer-invented.
675
675
  export const AgOutcome = z.discriminatedUnion("type", [
676
676
  z.object({ type: z.literal("success"), result: JsonValue.optional() }),
677
677
  // retriable (draft.5): the producer's judgement, recorded from turn.error; absent = unstated, not false.
@@ -794,17 +794,17 @@ export const AgTurnRecord = z.object({
794
794
  sourceIds: z.array(z.string()).optional(),
795
795
  sources: z.array(z.object({
796
796
  sourceId: z.string(),
797
- source: AgSourcePayload, // the §4 source arm's payload union, landed verbatim (audit M23)
797
+ source: AgSourcePayload, // the §4 source arm's payload union, landed verbatim
798
798
  chunkIndex: z.number().optional(),
799
799
  providerMetadata: AgProviderMeta.optional(),
800
- })).optional(), // grounding sources folded from source events (audit M23); sourceIds stays as the derived index
800
+ })).optional(), // grounding sources folded from source events; sourceIds stays as the derived index
801
801
  promptBlocked: z.object({
802
802
  reason: z.enum(["safety", "blocklist", "prohibited", "other"]), // mirrors the §4 prompt.blocked reason enum exactly
803
803
  reasonRaw: z.string().optional(), // folded from prompt.blocked.reasonRaw verbatim (draft.8)
804
804
  safety: z.array(AgSafety).optional(),
805
- }).optional(), // audit M28
805
+ }).optional(),
806
806
  asks: z.array(AgPausedAsk).optional(),
807
- taskState: z.string().optional(), // verbatim A2A TaskState (never reducer-invented — audit M29); no outcome-target mapping (A44)
807
+ taskState: z.string().optional(), // verbatim A2A TaskState (never reducer-invented); no outcome-target mapping
808
808
  displayRequired: z.array(AgDisplayRequired).optional(),
809
809
  trigger: AgTrigger.optional(), // what triggered this turn (A2-additive)
810
810
  guardrails: z.array(z.object({
@@ -949,7 +949,7 @@ export type AgRunConfig = z.infer<typeof AgRunConfig>;
949
949
 
950
950
  // The spec version this SDK implements (SPEC.md status line + §12). Consumers
951
951
  // reject a MAJOR mismatch and accept any same-major version (§12 negotiation).
952
- export const AGJSON_VERSION = "1.0.0-draft.8";
952
+ export const AGJSON_VERSION = "1.0.0-rc.2";
953
953
 
954
954
  const agjsonWireVersion = z
955
955
  .string()
@@ -1010,18 +1010,29 @@ const surfaceEnvelope = {
1010
1010
 
1011
1011
  // A2UI v1.0 client→server `action` (A2UI-frozen names VERBATIM, §0.4). `context`
1012
1012
  // = the A2UI resolved data-bindings — the SOLE sanctioned Record<string, unknown>
1013
- // (map shape known: string keys; each value opaque per §0.1).
1014
- export const AgA2uiSurfaceAction = z.object({
1015
- ...surfaceEnvelope,
1016
- surface: z.literal("a2ui"),
1017
- a2uiMessage: z.literal("action"),
1018
- name: z.string(),
1019
- sourceComponentId: z.string(),
1020
- timestamp: z.string(),
1021
- context: z.record(z.string(), z.unknown()),
1022
- wantResponse: z.boolean().optional(),
1023
- actionId: z.string().optional(),
1024
- });
1013
+ // (map shape known: string keys; each value opaque per §0.1). `actionId` is
1014
+ // REQUIRED when `wantResponse` is true (§3).
1015
+ export const AgA2uiSurfaceAction = z
1016
+ .object({
1017
+ ...surfaceEnvelope,
1018
+ surface: z.literal("a2ui"),
1019
+ a2uiMessage: z.literal("action"),
1020
+ name: z.string(),
1021
+ sourceComponentId: z.string(),
1022
+ timestamp: z.string(),
1023
+ context: z.record(z.string(), z.unknown()),
1024
+ wantResponse: z.boolean().optional(),
1025
+ actionId: z.string().optional(),
1026
+ })
1027
+ .superRefine((v, ctx) => {
1028
+ if (v.wantResponse === true && v.actionId === undefined) {
1029
+ ctx.addIssue({
1030
+ code: "custom",
1031
+ message: "wantResponse: true requires actionId (A2UI v1.0 action)",
1032
+ path: ["actionId"],
1033
+ });
1034
+ }
1035
+ });
1025
1036
  export type AgA2uiSurfaceAction = z.infer<typeof AgA2uiSurfaceAction>;
1026
1037
 
1027
1038
  // A2UI v1.0 client→server `functionResponse` (inbound leg of the server
@@ -1146,7 +1157,7 @@ export type AgOpenAiWidgetAction = z.infer<typeof AgOpenAiWidgetAction>;
1146
1157
  // (a2uiMessage / method), so a validation issue names the member that is
1147
1158
  // actually wrong: a plain z.union let every non-matching branch report its
1148
1159
  // own `surface` literal, and the input check (input-check.ts) misclassified
1149
- // e.g. an mcp-app ui/open-link with a non-string url (CB-9). Same members,
1160
+ // e.g. an mcp-app ui/open-link with a non-string url. Same members,
1150
1161
  // same literals, same accepted values; only the failure path is exact.
1151
1162
  export const AgSurfaceInteraction = z.discriminatedUnion("surface", [
1152
1163
  z.discriminatedUnion("a2uiMessage", [AgA2uiSurfaceAction, AgA2uiFunctionResponse, AgA2uiError]),
@@ -1307,7 +1318,7 @@ export const AgClosedEvent = z.discriminatedUnion("type", [
1307
1318
  id: z.string(),
1308
1319
  phase: z.string().optional(), // draft.4: REPLACES the start value when present
1309
1320
  providerMetadata: AgProviderMeta.optional(),
1310
- // STREAMED-text citations carrier (audit M22): citations for a streamed text
1321
+ // STREAMED-text citations carrier: citations for a streamed text
1311
1322
  // block arrive here (not as a duplicate id-less supplement block) and attach
1312
1323
  // to the sealed block named by `id` (spec §5 text.end row).
1313
1324
  citations: z.array(AgCitation).optional(),
@@ -1553,7 +1564,7 @@ export const AgClosedEvent = z.discriminatedUnion("type", [
1553
1564
  artifacts: z.array(AgArtifact).optional(),
1554
1565
  memory: z.array(AgMemoryRecord).optional(),
1555
1566
  }),
1556
- // ── HOST DISPLAY/RUNTIME HINT ── live-only; `capabilities` here = HOST surface render hint (A30).
1567
+ // ── HOST DISPLAY/RUNTIME HINT ── live-only; `capabilities` here = HOST surface render hint.
1557
1568
  z.object({
1558
1569
  ...base,
1559
1570
  type: z.literal("host.context"),
@@ -1601,7 +1612,7 @@ export const AgClosedEvent = z.discriminatedUnion("type", [
1601
1612
  ...base,
1602
1613
  type: z.literal("ui.display-mode"),
1603
1614
  mode: AgDisplayMode,
1604
- granted: AgDisplayMode.optional(), // authoritative reply leg (A52)
1615
+ granted: AgDisplayMode.optional(), // authoritative reply leg
1605
1616
  surfaceId: z.string().optional(),
1606
1617
  toolCallId: z.string().optional(),
1607
1618
  }),
@@ -1,6 +1,6 @@
1
1
  /**
2
- * atomic-push.ts — per-native atomicity for a Normalizer (the fleet guard
3
- * ruling, 2026-09-24, binding; sp-main approved sp-openai's option B).
2
+ * atomic-push.ts — per-native atomicity for a Normalizer (the no-throw guard
3
+ * ruling, 2026-09-24, binding: option B).
4
4
  *
5
5
  * A Normalizer MUST NOT throw out of push() (SPEC.md §8.0). When handling
6
6
  * one native throws anyway, the events it had already produced must be
@@ -50,19 +50,23 @@ export function normalizerErrorCode(err: unknown): string {
50
50
  */
51
51
  export interface AtomicPushOptions {
52
52
  /** Run {@link toJsonValueSafe} on each native before the inner push (default
53
- * true). With it the journal holds a JSON deep copy of what the inner saw,
54
- * so a host mutating a pushed native later cannot skew a rebuild. With
55
- * `false` a native that is already plain JSON is still journaled as a deep
56
- * copy; any other native (a class instance, a Date, a cycle) is journaled
57
- * BY REFERENCE, so the caller must pass values it owns and never mutate one
58
- * after pushing it. */
53
+ * true). With it the inner is handed a JSON deep copy of the native, taken
54
+ * before the inner sees it, and the journal keeps that same copy: a host
55
+ * mutating a pushed native later changes neither an emitted event nor a
56
+ * rebuild. With `false` a native that is already plain JSON is still
57
+ * copied the same way; any other native (a class instance, a Date, a
58
+ * cycle) is handed over and journaled BY REFERENCE, so the caller must pass
59
+ * values it owns and never mutate one after pushing it. */
59
60
  normalize?: boolean;
60
61
  }
61
62
 
62
63
  /**
63
64
  * Wrap a Normalizer factory so each push() (and flush()) is atomic:
64
65
  * - Success: the inner's events are returned (by reference; unchanged until a
65
- * throw has happened), and the native joins the journal.
66
+ * throw has happened), and the native's copy joins the journal. The inner
67
+ * is pushed that copy, never the host's object, so no emitted event shares
68
+ * an object with the native the host passed in (except a non-JSON native
69
+ * under `normalize: false`; see {@link AtomicPushOptions}).
66
70
  * - Throw: the partial batch is discarded, the inner is rebuilt and re-driven
67
71
  * from the journal with its output dropped (a throw during that re-drive is
68
72
  * caught too), and ONE core `error {message: "normalizer error", code}`
@@ -85,8 +89,10 @@ export interface AtomicPushOptions {
85
89
  * turn.abort{stream-truncated} for each open turn, innermost first.
86
90
  *
87
91
  * Costs, by design (caps deferred):
88
- * - Memory: O(invoke). The journal keeps a COPY of every accepted native (a
89
- * JSON deep copy when normalizing, never the host's reference) for the life
92
+ * - Memory: O(invoke). The journal keeps the COPY each accepted native was
93
+ * pushed as (a JSON deep copy when normalizing, never the host's reference;
94
+ * the inner and the journal share it, and a facet never mutates its input)
95
+ * for the life
90
96
  * of the instance, i.e. one invoke, since hosts build a fresh Normalizer per
91
97
  * invoke (§8.0 obligation 3).
92
98
  * - Time: O(bad × prefix). Each throw re-drives the invoke so far, output
@@ -204,8 +210,14 @@ export function withAtomicPush(createInner: () => Normalizer, opts: AtomicPushOp
204
210
  push(native: unknown): AgEvent[] {
205
211
  try {
206
212
  const n: unknown = normalize ? toJsonValueSafe(native) : native;
207
- const evs = inner.push(n);
208
- journal.push(normalize || isJsonValue(n) ? toJsonValue(n as JsonValue) : n);
213
+ // One copy, taken BEFORE the inner sees it: toJsonValueSafe hands plain
214
+ // JSON back as the host's own object, so without it an event the inner
215
+ // builds could share a node with the native, and a host mutating its
216
+ // native after push() would change an event already delivered. The
217
+ // journal keeps the same copy for a rebuild.
218
+ const owned: unknown = normalize || isJsonValue(n) ? toJsonValue(n as JsonValue) : n;
219
+ const evs = inner.push(owned);
220
+ journal.push(owned);
209
221
  return deliver(evs);
210
222
  } catch (err) {
211
223
  rebuild();
package/src/copy-json.ts CHANGED
@@ -1,17 +1,23 @@
1
1
  /**
2
- * copy-json.ts — INTERNAL (not re-exported from index.ts).
2
+ * copy-json.ts
3
3
  *
4
4
  * The one own-property deep copy every consumer-side reader in core uses, so
5
- * the §13 rule on `__proto__` has a single code path: stage-1 ingest
5
+ * the §13.7 rule on `__proto__` has a single code path: stage-1 ingest
6
6
  * (ingest.ts), the stored-record readers (record.ts) and the input check
7
- * (input-check.ts).
7
+ * (input-check.ts). `copyJson` is exported for hosts that seed a fold from
8
+ * their own store. The two walks below apply the same omission on the fold's
9
+ * and the emitter's own paths.
8
10
  */
9
11
  import type { JsonValue } from "./agjson.js";
10
12
 
11
13
  /**
12
- * Own-property deep copy of a JSON value, dropping `__proto__` at every depth.
14
+ * Own-property deep copy of a JSON value, dropping an own `__proto__` member at
15
+ * every depth. Every object and array in the copy has the ordinary prototype.
16
+ * A host that seeds a fold from its own store copies the stored value with it.
13
17
  * The copy is iterative, so no nesting depth overflows the stack; a node
14
18
  * reached twice is copied once.
19
+ *
20
+ * @beta
15
21
  */
16
22
  export function copyJson(v: JsonValue): JsonValue {
17
23
  type Node = JsonValue[] | { [k: string]: JsonValue };
@@ -48,3 +54,125 @@ export function copyJson(v: JsonValue): JsonValue {
48
54
  }
49
55
  return root;
50
56
  }
57
+
58
+ const PROTO = "__proto__";
59
+
60
+ /** True for an object this module treats as a JSON node: an array or a plain-or-null-prototype object. */
61
+ function isPlainNode(v: object): boolean {
62
+ if (Array.isArray(v)) return true;
63
+ const proto: unknown = Object.getPrototypeOf(v);
64
+ return proto === Object.prototype || proto === null;
65
+ }
66
+
67
+ /**
68
+ * INTERNAL. Removes an own `__proto__` member at every depth of a value the
69
+ * caller owns (a structuredClone copy). `delete` removes own members only, so
70
+ * a node without one is untouched. The walk is iterative and visits each
71
+ * object once, so neither nesting depth nor a cycle bounds it.
72
+ */
73
+ export function deleteOwnProtoMember(v: unknown): void {
74
+ const seen = new WeakSet<object>();
75
+ const stack: unknown[] = [v];
76
+ while (stack.length > 0) {
77
+ const x = stack.pop();
78
+ if (x === null || typeof x !== "object" || seen.has(x)) continue;
79
+ seen.add(x);
80
+ if (Array.isArray(x)) {
81
+ for (let i = 0; i < x.length; i++) stack.push(x[i]);
82
+ continue;
83
+ }
84
+ const o = x as Record<string, unknown>;
85
+ if (Object.hasOwn(o, PROTO)) delete o[PROTO];
86
+ for (const k in o) if (Object.hasOwn(o, k)) stack.push(o[k]);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * INTERNAL. A copy of `v` without an own `__proto__` member at any depth that
92
+ * never mutates `v`: when any node holds the member, its arrays and plain (or
93
+ * null-prototype) objects are rebuilt with the ordinary prototype, members DEFINED, never
94
+ * assigned; any other value (a function, a class instance) is carried by
95
+ * reference. Returns `v` itself when no node holds the member, so the common
96
+ * case allocates nothing. Both walks are iterative and visit each object once:
97
+ * a node reached twice is copied once, and a cycle is copied as a cycle.
98
+ */
99
+ export function withoutOwnProtoMember<T>(v: T): T {
100
+ return (hasOwnProtoMember(v) ? rebuild(v) : v) as T;
101
+ }
102
+
103
+ /**
104
+ * The plain nodes the fast pass visits before it hands the value to the pass
105
+ * that remembers each node. An emitted event is a tree, so remembering costs
106
+ * it a WeakSet entry per node for nothing; a value that shares nodes or holds a
107
+ * cycle can make the fast pass revisit them without end, and the budget turns
108
+ * that into the remembering pass. The fold side's scan (depth.ts) works the
109
+ * same way.
110
+ */
111
+ const PROTO_SCAN_NODE_BUDGET = 50_000;
112
+
113
+ function hasOwnProtoMember(v: unknown): boolean {
114
+ return protoScan(v, false) ?? protoScan(v, true)!;
115
+ }
116
+
117
+ /**
118
+ * One iterative pass over the arrays and plain (or null-prototype) objects of
119
+ * `v`: whether any such object holds an own `__proto__` member. With
120
+ * `remember`, each node is visited once; without, it returns undefined once it
121
+ * has visited PROTO_SCAN_NODE_BUDGET nodes.
122
+ */
123
+ function protoScan(v: unknown, remember: boolean): boolean | undefined {
124
+ const seen = remember ? new WeakSet<object>() : undefined;
125
+ let visits = 0;
126
+ const stack: unknown[] = [v];
127
+ while (stack.length > 0) {
128
+ const x = stack.pop();
129
+ if (x === null || typeof x !== "object" || !isPlainNode(x)) continue;
130
+ if (seen !== undefined) {
131
+ if (seen.has(x)) continue;
132
+ seen.add(x);
133
+ } else if (++visits > PROTO_SCAN_NODE_BUDGET) {
134
+ return undefined;
135
+ }
136
+ if (Array.isArray(x)) {
137
+ for (let i = 0; i < x.length; i++) stack.push(x[i]);
138
+ continue;
139
+ }
140
+ if (Object.hasOwn(x, PROTO)) return true;
141
+ for (const k of Object.keys(x)) stack.push((x as Record<string, unknown>)[k]);
142
+ }
143
+ return false;
144
+ }
145
+
146
+ function rebuild(v: unknown): unknown {
147
+ const copies = new Map<object, unknown[] | Record<string, unknown>>();
148
+ const pending: object[] = [];
149
+ const copyOf = (x: unknown): unknown => {
150
+ if (x === null || typeof x !== "object" || !isPlainNode(x)) return x;
151
+ let c = copies.get(x);
152
+ if (c === undefined) {
153
+ c = Array.isArray(x) ? new Array<unknown>(x.length) : {};
154
+ copies.set(x, c);
155
+ pending.push(x);
156
+ }
157
+ return c;
158
+ };
159
+ const root = copyOf(v);
160
+ while (pending.length > 0) {
161
+ const x = pending.pop()!;
162
+ const c = copies.get(x)!;
163
+ if (Array.isArray(x)) {
164
+ for (let i = 0; i < x.length; i++) if (i in x) (c as unknown[])[i] = copyOf(x[i]);
165
+ continue;
166
+ }
167
+ for (const k of Object.keys(x)) {
168
+ if (k === PROTO) continue;
169
+ Object.defineProperty(c, k, {
170
+ value: copyOf((x as Record<string, unknown>)[k]),
171
+ enumerable: true,
172
+ writable: true,
173
+ configurable: true,
174
+ });
175
+ }
176
+ }
177
+ return root;
178
+ }
package/src/depth.ts CHANGED
@@ -7,16 +7,6 @@
7
7
  */
8
8
 
9
9
  import type { JsonValue } from "./agjson.js";
10
- import { JSON_SAFE_MAX_DEPTH } from "./wire.js";
11
-
12
- /** The levels an event's own members may add above a carried value that toJsonValueSafe capped at JSON_SAFE_MAX_DEPTH. */
13
- export const AG_EVENT_DEPTH_ALLOWANCE = 16;
14
- /**
15
- * The deepest node an event may hold, counted from the event root: the root is
16
- * at depth 0 and a node's depth is the number of containers above it.
17
- * JSON_SAFE_MAX_DEPTH plus AG_EVENT_DEPTH_ALLOWANCE.
18
- */
19
- export const AG_EVENT_MAX_DEPTH = JSON_SAFE_MAX_DEPTH + AG_EVENT_DEPTH_ALLOWANCE;
20
10
 
21
11
  /** What one scan of a value found: a node past the bound, and an own `__proto__` member. */
22
12
  export interface DepthScan {
package/src/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./atomic-push.js";
7
7
  export * from "./record.js";
8
8
  export * from "./input-check.js";
9
9
  export * from "./persist.js";
10
+ export { copyJson } from "./copy-json.js";
package/src/ingest.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Consumer-ingestion posture (SPEC §0.2 / §12; audit B5).
2
+ * Consumer-ingestion posture (SPEC §0.2 / §12).
3
3
  *
4
4
  * A consumer validating incoming events MUST parse-known-else-skip and pass
5
5
  * unknown fields through, so additive-minor spec revisions survive. This is
@@ -32,7 +32,7 @@
32
32
  * typed ext event: it never folds, but a Reducer counts its `seq` slot,
33
33
  * so an ignored event can no longer open a false gap. `raw` is the
34
34
  * original frame (same copy rules) and is LIVE-ONLY: never persist it.
35
- * An envelope holding a node deeper than the event depth bound becomes the
35
+ * An envelope holding a node deeper than AG_EVENT_MAX_DEPTH becomes the
36
36
  * same stub without being parsed, since the schema parse's recursion
37
37
  * would overflow on it; its `raw` is the frame as toJsonValueSafe
38
38
  * renders it, cut off at JSON_SAFE_MAX_DEPTH, so the stub itself stays
@@ -44,8 +44,8 @@
44
44
  */
45
45
  import { AgEvent, type JsonValue } from "./agjson.js";
46
46
  import { copyJson } from "./copy-json.js";
47
- import { AG_EVENT_MAX_DEPTH, exceedsDepth } from "./depth.js";
48
- import { JSON_SAFE_MAX_DEPTH_MARK, toJsonValueSafe } from "./wire.js";
47
+ import { exceedsDepth } from "./depth.js";
48
+ import { AG_EVENT_MAX_DEPTH, JSON_SAFE_MAX_DEPTH_MARK, toJsonValueSafe } from "./wire.js";
49
49
 
50
50
  /** Why an input is not a well-formed envelope (draft.4 §0.2). */
51
51
  export type AgIngestRejectReason = "not-object" | "type-not-string" | "seq-not-number";
package/src/json-patch.ts CHANGED
@@ -16,6 +16,7 @@ import type { JsonValue } from "./agjson.js";
16
16
  // RFC-6901 pointer parsing:
17
17
  // • split on "/"; unescape "~1" → "/" then "~0" → "~" (ORDER MATTERS).
18
18
  // • "" (empty pointer) = the whole document (root replacement).
19
+ // • A reference token "__proto__" fails the operation (path or from).
19
20
  //
20
21
  // Member resolution: a token names an object member only when the object holds
21
22
  // it as its OWN member; an inherited name (toString, constructor, …) is absent.
@@ -61,10 +62,13 @@ function isJsonArray(v: JsonValue): v is JsonValue[] {
61
62
  function parsePointer(ptr: string): string[] | null {
62
63
  if (ptr === "") return [];
63
64
  if (!ptr.startsWith("/")) return null; // malformed — must start with "/"
64
- return ptr
65
+ const tokens = ptr
65
66
  .slice(1)
66
67
  .split("/")
67
68
  .map((tok) => tok.replace(/~1/g, "/").replace(/~0/g, "~"));
69
+ // A "__proto__" token never names a member: the operation fails.
70
+ if (tokens.includes("__proto__")) return null;
71
+ return tokens;
68
72
  }
69
73
 
70
74
  /** The object's OWN member `tok`, or undefined when it holds none (inherited names included). */
package/src/record.ts CHANGED
@@ -36,8 +36,8 @@
36
36
  */
37
37
  import { AgBlock, AgMemoryRecord, AgMessage, type JsonValue } from "./agjson.js";
38
38
  import { copyJson } from "./copy-json.js";
39
- import { toJsonValueSafe } from "./wire.js";
40
- import { AG_EVENT_DEPTH_ALLOWANCE, AG_EVENT_MAX_DEPTH, isJsonValueWithin } from "./depth.js";
39
+ import { AG_EVENT_DEPTH_ALLOWANCE, AG_EVENT_MAX_DEPTH, toJsonValueSafe } from "./wire.js";
40
+ import { isJsonValueWithin } from "./depth.js";
41
41
 
42
42
  /**
43
43
  * The deepest node a stored record may hold, from its root. The fold places a