@avatarsd-llc/libtracer-client 0.7.0 → 0.8.0

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/fwd.d.ts CHANGED
@@ -131,11 +131,11 @@ export declare function encodeFwd(req: FwdRequest): Uint8Array;
131
131
  export interface ParsedFwd {
132
132
  /** @brief The operation (a {@link FWD_OP} value). */
133
133
  readonly op: number;
134
- /** @brief The `dst` PATH child. */
134
+ /** @brief The `dst` route child — a `PATH`, or a `PATH_REF` when {@link dstBound}. */
135
135
  readonly dst: Tlv;
136
136
  /** @brief The optional FIELD selector child (or `null`). */
137
137
  readonly field: Tlv | null;
138
- /** @brief The `src` PATH child. */
138
+ /** @brief The `src` route child — a `PATH`, or a `PATH_REF` on a reply to a bound op. */
139
139
  readonly src: Tlv;
140
140
  /** @brief The reply {@link FWD_KIND} (REPLY frames only, else `null`). */
141
141
  readonly kind: number | null;
@@ -143,7 +143,27 @@ export interface ParsedFwd {
143
143
  readonly payload: Tlv | null;
144
144
  /** @brief The AWAIT `await_timeout` ns (else `null`). */
145
145
  readonly awaitTimeoutNs: bigint | null;
146
+ /** @brief `op` bit 7 was set — the origin asked for a bound-path mint (RFC-0024 §7.5). */
147
+ readonly mintRequest: boolean;
148
+ /** @brief `dst` is a `PATH_REF` (`0x14`), not a canonical `PATH` (RFC-0024 §4). */
149
+ readonly dstBound: boolean;
146
150
  }
151
+ /**
152
+ * @brief The opcode field of the `op` byte — bits 5-0 (RFC-0024 §7.5).
153
+ *
154
+ * Bits 7-6 are FLAGS. A forwarder MUST mask before switching (RFC-0024 §9.3): an
155
+ * unrecognised flag then degrades to the plain opcode instead of an unknown-opcode reject,
156
+ * which is what makes a flag additive at all.
157
+ */
158
+ export declare const FWD_OPCODE_MASK = 63;
159
+ /**
160
+ * @brief `op` bit 7 — the bound-path MINT REQUEST (RFC-0024 §7.5).
161
+ *
162
+ * Set by an origin asking each host on the route to answer with its own vertex ref. It costs
163
+ * ZERO request bytes: there is no free TLV `opt` bit, and a dedicated presence child would
164
+ * spend a 4-byte header to express one. The request is a hint, never an obligation.
165
+ */
166
+ export declare const FWD_OP_FLAG_MINT_REQUEST = 128;
147
167
  /** @brief Parse an already-decoded FWD {@link Tlv} positionally (RFC-0004 §B). */
148
168
  export declare function parseFwdTlv(fwd: Tlv): ParsedFwd;
149
169
  /**
package/dist/fwd.js CHANGED
@@ -223,6 +223,22 @@ export function encodeFwd(req) {
223
223
  };
224
224
  return encode(fwd);
225
225
  }
226
+ /**
227
+ * @brief The opcode field of the `op` byte — bits 5-0 (RFC-0024 §7.5).
228
+ *
229
+ * Bits 7-6 are FLAGS. A forwarder MUST mask before switching (RFC-0024 §9.3): an
230
+ * unrecognised flag then degrades to the plain opcode instead of an unknown-opcode reject,
231
+ * which is what makes a flag additive at all.
232
+ */
233
+ export const FWD_OPCODE_MASK = 0x3f;
234
+ /**
235
+ * @brief `op` bit 7 — the bound-path MINT REQUEST (RFC-0024 §7.5).
236
+ *
237
+ * Set by an origin asking each host on the route to answer with its own vertex ref. It costs
238
+ * ZERO request bytes: there is no free TLV `opt` bit, and a dedicated presence child would
239
+ * spend a 4-byte header to express one. The request is a hint, never an obligation.
240
+ */
241
+ export const FWD_OP_FLAG_MINT_REQUEST = 0x80;
226
242
  const u8 = (t) => (t.payload.length > 0 ? t.payload[0] : 0);
227
243
  /** @brief Parse an already-decoded FWD {@link Tlv} positionally (RFC-0004 §B). */
228
244
  export function parseFwdTlv(fwd) {
@@ -232,15 +248,25 @@ export function parseFwdTlv(fwd) {
232
248
  let i = 0;
233
249
  if (ch[i]?.type !== TYPE.VALUE)
234
250
  throw new RangeError('FWD: missing op VALUE child');
235
- const op = u8(ch[i++]);
236
- if (ch[i]?.type !== TYPE.PATH)
251
+ // The opcode is `op & 0x3F`; bits 7-6 are flags (RFC-0024 §7.5, normative in §9.3).
252
+ // Switching on the raw byte would make a mint-flagged READ an unknown opcode here.
253
+ const opByte = u8(ch[i++]);
254
+ const op = opByte & FWD_OPCODE_MASK;
255
+ const mintRequest = (opByte & FWD_OP_FLAG_MINT_REQUEST) !== 0;
256
+ // Two address forms (RFC-0024 §4): a canonical PATH, or a bound PATH_REF whose body shape
257
+ // the grammar has already checked. What an element MEANS is node-scoped, so a binding core
258
+ // carries one and never interprets it.
259
+ const dstBound = ch[i]?.type === TYPE.PATH_REF;
260
+ if (!dstBound && ch[i]?.type !== TYPE.PATH)
237
261
  throw new RangeError('FWD: missing dst PATH child');
238
262
  const dst = ch[i++];
239
263
  let field = null;
240
264
  if (ch[i]?.type === TYPE.FIELD)
241
265
  field = ch[i++];
242
- if (ch[i]?.type !== TYPE.PATH)
266
+ // `src` takes either form too: a reply to a bound operation echoes the request's `dst`.
267
+ if (ch[i]?.type !== TYPE.PATH && ch[i]?.type !== TYPE.PATH_REF) {
243
268
  throw new RangeError('FWD: missing src PATH child');
269
+ }
244
270
  const src = ch[i++];
245
271
  let kind = null;
246
272
  let payload = null;
@@ -261,7 +287,7 @@ export function parseFwdTlv(fwd) {
261
287
  i++;
262
288
  }
263
289
  }
264
- return { op, dst, field, src, kind, payload, awaitTimeoutNs };
290
+ return { op, dst, field, src, kind, payload, awaitTimeoutNs, mintRequest, dstBound };
265
291
  }
266
292
  /**
267
293
  * @brief Decode a complete FWD frame's bytes into its parsed children.
package/dist/index.d.ts CHANGED
@@ -20,5 +20,5 @@ export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, DELIVERY_DUR
20
20
  export type { ValueOptions, SubscriberOptions, ConnSpecOptions, ConnRole } from './tlv.js';
21
21
  export { walkTopology, routeKey } from './topology.js';
22
22
  export type { TopologyGraph, TopologyNode, TopologyEdge, TopologyBusPeers, TopologyGap, WalkOptions, } from './topology.js';
23
- export { FWD_OP, FWD_KIND, FWD_ERROR, FWD_ERROR_PATH, fwdErrorName, fwdErrorPath, fwdErrorCodeForPath, encodeFwd, encodeField, parseField, decodeFwd, parseFwdTlv, replyErrorCode, replyErrorPath, } from './fwd.js';
23
+ export { FWD_OP, FWD_OPCODE_MASK, FWD_OP_FLAG_MINT_REQUEST, FWD_KIND, FWD_ERROR, FWD_ERROR_PATH, fwdErrorName, fwdErrorPath, fwdErrorCodeForPath, encodeFwd, encodeField, parseField, decodeFwd, parseFwdTlv, replyErrorCode, replyErrorPath, } from './fwd.js';
24
24
  export type { FwdRequest, ParsedFwd, FieldLevel } from './fwd.js';
package/dist/index.js CHANGED
@@ -19,4 +19,4 @@ export const CLIENT_EXPERIMENTAL = true;
19
19
  export { LibtracerClient, FwdError, CompactFlowError } from './client.js';
20
20
  export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, DELIVERY_DURABILITY_REQUEST } from './tlv.js';
21
21
  export { walkTopology, routeKey } from './topology.js';
22
- export { FWD_OP, FWD_KIND, FWD_ERROR, FWD_ERROR_PATH, fwdErrorName, fwdErrorPath, fwdErrorCodeForPath, encodeFwd, encodeField, parseField, decodeFwd, parseFwdTlv, replyErrorCode, replyErrorPath, } from './fwd.js';
22
+ export { FWD_OP, FWD_OPCODE_MASK, FWD_OP_FLAG_MINT_REQUEST, FWD_KIND, FWD_ERROR, FWD_ERROR_PATH, fwdErrorName, fwdErrorPath, fwdErrorCodeForPath, encodeFwd, encodeField, parseField, decodeFwd, parseFwdTlv, replyErrorCode, replyErrorPath, } from './fwd.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avatarsd-llc/libtracer-client",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "EXPERIMENTAL libtracer client SDK (#56, ADR-0034/0035) — a path-addressed client over the cross-validated codec (@avatarsd-llc/libtracer) and an injected transport seam (e.g. @avatarsd-llc/libtracer-ws). Speaks the RFC-0004 remote operations over FWD: read / write / await / readField / subscribe, each a FWD frame whose source-routed FWD{REPLY} is decoded back. Pre-1.0 and experimental.",
5
5
  "author": "avatarsd LLC",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,8 @@
33
33
  "access": "public"
34
34
  },
35
35
  "peerDependencies": {
36
- "@avatarsd-llc/libtracer": ">=0.7.0 <0.8.0",
37
- "@avatarsd-llc/libtracer-ws": ">=0.7.0 <0.8.0"
36
+ "@avatarsd-llc/libtracer": ">=0.8.0 <0.9.0",
37
+ "@avatarsd-llc/libtracer-ws": ">=0.8.0 <0.9.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@avatarsd-llc/libtracer-ws": {