@avatarsd-llc/libtracer-client 0.8.0 → 0.9.1

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
@@ -62,7 +62,7 @@ encodeField(':subscribers[]'); // === field-appe
62
62
  | `encodeFwd` / `encodeField` builders + `decodeFwd` | **implemented** | `fwd-*`, `field-*`, `fwd-reply-*` |
63
63
  | `encodeValue` / `encodeSubscriber` / `encodePath` payload builders | **implemented** | `value-bool-true`, `value-ll-u32`, `value-ts-abs`, `subscriber-path`, `path-sensor-temp` |
64
64
  | inbound VALUE delivery (FWD{WRITE} / bare / ROUTER-shed) | **implemented** | `router-wrapped` + all vectors |
65
- | typed `FwdError` on `kind=ERROR` reply | **implemented** (codes provisional) | `fwd-reply-error`; ERROR registry (#8) pins the code set |
65
+ | typed `FwdError` on `kind=ERROR` reply | **implemented** (codes provisional) | `fwd-reply-error`; ERROR registry (#8) pins the code set. The ERROR is the first `ERROR` child of the STATUS **at whatever position** — `fwd-reply-error-after-description` pins that rule here and in the Rust binding |
66
66
 
67
67
  ## Dependencies
68
68
 
package/dist/fwd.js CHANGED
@@ -18,7 +18,7 @@
18
18
  * - READ : nothing
19
19
  */
20
20
  import { TYPE, encode, decode } from '@avatarsd-llc/libtracer';
21
- import { opt, pathTlv, nameTlv } from './tlv.js';
21
+ import { opt, pathTlv, nameTlv, firstChild } from './tlv.js';
22
22
  /** @brief FWD `op` discriminant (RFC-0004 §B — the first child, a VALUE u8). */
23
23
  export const FWD_OP = Object.freeze({
24
24
  READ: 0,
@@ -299,12 +299,25 @@ export function parseFwdTlv(fwd) {
299
299
  export function decodeFwd(bytes) {
300
300
  return parseFwdTlv(decode(bytes));
301
301
  }
302
- /** @brief The ERROR TLV of a `kind=ERROR` reply's STATUS payload, or `null`. */
302
+ /**
303
+ * @brief The ERROR TLV of a `kind=ERROR` reply's STATUS payload, or `null`.
304
+ *
305
+ * The **first ERROR child of the STATUS, at whatever position** — never
306
+ * `children[0]`. reference/05 §`0x09` gives a STATUS "one or more ERROR TLVs
307
+ * and optional DESCRIPTION text" and pins no order over them; RFC-0002 §C pins
308
+ * position only one level down, INSIDE the ERROR ("its first child is the
309
+ * identity"). Demanding position 0 here therefore refuses a documented STATUS
310
+ * shape and answers code 0 — indistinguishable from a STATUS carrying no ERROR
311
+ * at all, so a peer's typed failure reads as no failure information.
312
+ *
313
+ * Vector-pinned by `fwd/fwd-reply-error-after-description` (the DESCRIPTION
314
+ * written first), which the Rust binding pins against the same bytes so the
315
+ * two cores cannot drift apart on it again (#878).
316
+ */
303
317
  function replyErrorTlv(reply) {
304
318
  const status = reply.payload;
305
- if (status && status.type === TYPE.STATUS && status.children[0]?.type === TYPE.ERROR) {
306
- return status.children[0];
307
- }
319
+ if (status && status.type === TYPE.STATUS)
320
+ return firstChild(status, TYPE.ERROR);
308
321
  return null;
309
322
  }
310
323
  /**
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  export declare const CLIENT_EXPERIMENTAL: true;
17
17
  export { LibtracerClient, FwdError, CompactFlowError } from './client.js';
18
18
  export type { ClientTransport, ValueHandler, Unsubscribe, ClientOptions, } from './client.js';
19
- export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, DELIVERY_DURABILITY_REQUEST } from './tlv.js';
19
+ export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, firstChild, DELIVERY_DURABILITY_REQUEST } from './tlv.js';
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';
package/dist/index.js CHANGED
@@ -17,6 +17,6 @@
17
17
  */
18
18
  export const CLIENT_EXPERIMENTAL = true;
19
19
  export { LibtracerClient, FwdError, CompactFlowError } from './client.js';
20
- export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, DELIVERY_DURABILITY_REQUEST } from './tlv.js';
20
+ export { encodeValue, encodePath, encodeSubscriber, encodeConnSpec, firstChild, DELIVERY_DURABILITY_REQUEST } from './tlv.js';
21
21
  export { walkTopology, routeKey } from './topology.js';
22
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/dist/tlv.d.ts CHANGED
@@ -1,4 +1,28 @@
1
1
  import type { Opt, Tlv } from '@avatarsd-llc/libtracer';
2
+ /**
3
+ * @brief The first DIRECT child of `tlv` with the given type code, or `null`.
4
+ *
5
+ * The one child-by-type accessor this package reads structure through, and the
6
+ * mirror of the Rust binding's `Tlv::first_child` — both cores answer a
7
+ * structured TLV's "the X child" question by scanning direct children for the
8
+ * first matching TYPE, never by indexing a fixed position. Open-coding
9
+ * `children[0]?.type === TYPE.X` instead is how the two bindings drifted apart
10
+ * on `STATUS{ … ERROR … }` (#878): it silently reads a positional rule into a
11
+ * grammar that pins none, and the reader that indexes reports "no such child"
12
+ * for a child that is right there.
13
+ *
14
+ * Direct children only — a match is never searched for inside a grandchild,
15
+ * since a nested TLV of the same type is a DIFFERENT thing (an ERROR's own
16
+ * detail child, say, is not the STATUS's error).
17
+ *
18
+ * @param tlv the structured (`opt.PL=1`) parent to scan
19
+ * @param type the wire type code to match — a value of the core codec's `TYPE`
20
+ * map (`TYPE.ERROR`, `TYPE.PATH`, …), not linked here because it is
21
+ * re-exported from `@avatarsd-llc/libtracer` and the docs gate
22
+ * refuses a cross-package link
23
+ * @returns the first matching child, or `null` when there is none
24
+ */
25
+ export declare function firstChild(tlv: Tlv | null | undefined, type: number): Tlv | null;
2
26
  /**
3
27
  * @brief A fully-cleared option byte (all flags false), with selected flags
4
28
  * overridden.
package/dist/tlv.js CHANGED
@@ -1,10 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: Copyright 2026 avatarsd LLC
3
3
  /**
4
- * @brief Pure, side-effect-free TLV builders for the libtracer client SDK
5
- * (#56, ADR-0034).
4
+ * @brief Pure, side-effect-free TLV builders — and the one shared child accessor
5
+ * that reads them back — for the libtracer client SDK (#56, ADR-0034).
6
6
  *
7
- * Each function produces the EXACT wire bytes the shared conformance vectors
7
+ * Each builder produces the EXACT wire bytes the shared conformance vectors
8
8
  * pin (`tests/conformance/vectors/v1/`) via the cross-validated core codec
9
9
  * (`@avatarsd-llc/libtracer`) — nothing here invents wire structure:
10
10
  *
@@ -12,11 +12,41 @@
12
12
  * - encodePath -> PATH TLV (0x06, PL=1) : path-sensor-temp + spec/v1.md §3.1
13
13
  * - encodeSubscriber -> SUBSCRIBER TLV (0x04) : subscriber-path (the subscribe-write payload)
14
14
  *
15
+ * Reading back, `firstChild` is the package's single child-by-type accessor and
16
+ * the mirror of the Rust binding's `Tlv::first_child`; it leads the file because
17
+ * every structured read goes through it rather than indexing a position (#878).
18
+ *
15
19
  * These are the payload TLVs. The path-ADDRESSED request envelope (verb +
16
20
  * destination vertex:field) is the FWD/FIELD frame RFC-0004 (spec §3) fixes —
17
21
  * it is built in `./fwd.ts`, not here; these payloads ride inside it.
18
22
  */
19
23
  import { TYPE, encode } from '@avatarsd-llc/libtracer';
24
+ /**
25
+ * @brief The first DIRECT child of `tlv` with the given type code, or `null`.
26
+ *
27
+ * The one child-by-type accessor this package reads structure through, and the
28
+ * mirror of the Rust binding's `Tlv::first_child` — both cores answer a
29
+ * structured TLV's "the X child" question by scanning direct children for the
30
+ * first matching TYPE, never by indexing a fixed position. Open-coding
31
+ * `children[0]?.type === TYPE.X` instead is how the two bindings drifted apart
32
+ * on `STATUS{ … ERROR … }` (#878): it silently reads a positional rule into a
33
+ * grammar that pins none, and the reader that indexes reports "no such child"
34
+ * for a child that is right there.
35
+ *
36
+ * Direct children only — a match is never searched for inside a grandchild,
37
+ * since a nested TLV of the same type is a DIFFERENT thing (an ERROR's own
38
+ * detail child, say, is not the STATUS's error).
39
+ *
40
+ * @param tlv the structured (`opt.PL=1`) parent to scan
41
+ * @param type the wire type code to match — a value of the core codec's `TYPE`
42
+ * map (`TYPE.ERROR`, `TYPE.PATH`, …), not linked here because it is
43
+ * re-exported from `@avatarsd-llc/libtracer` and the docs gate
44
+ * refuses a cross-package link
45
+ * @returns the first matching child, or `null` when there is none
46
+ */
47
+ export function firstChild(tlv, type) {
48
+ return tlv?.children.find((c) => c.type === type) ?? null;
49
+ }
20
50
  /** @brief Path-segment constraints from reference/03-addressing.md §path syntax. */
21
51
  const MAX_SEGMENT_BYTES = 64;
22
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avatarsd-llc/libtracer-client",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
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.8.0 <0.9.0",
37
- "@avatarsd-llc/libtracer-ws": ">=0.8.0 <0.9.0"
36
+ "@avatarsd-llc/libtracer": ">=0.9.1 <0.10.0",
37
+ "@avatarsd-llc/libtracer-ws": ">=0.9.1 <0.10.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@avatarsd-llc/libtracer-ws": {