@nac3/runtime 2.5.0-alpha.4 → 2.5.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.
@@ -1,13 +1,13 @@
1
1
  // Generated by build.mjs -- do not edit. Source: yujin.app/nac-spec/js/nac.js
2
2
  /* =====================================================================
3
3
  NAC3 (Native Agent Contract v3) -- reference JavaScript runtime.
4
- Spec: packages/nac/SPEC.md. Public docs: yujin.app/nac-spec/.
5
- MIT License -- Pablo Adrian Kuschniroff + Sumi, 2026.
4
+ Spec: SPEC.md (repo root). Public docs: yujin.app/nac-spec/.
5
+ Apache-2.0 License -- Pablo Adrian Kuschniroff + Sumi, 2026.
6
6
  =====================================================================
7
7
 
8
8
  AUTHORITATIVE VERSION CONSTANT: see the global.NAC export at the
9
- bottom of this file. `version: '2.4.0', spec_version: '2.4'` is
10
- the normative declaration. The dated changelog sections below are
9
+ bottom of this file. `version: '2.5.0', spec_version: '2.5'`
10
+ is the normative declaration. The dated changelog sections below are
11
11
  historical notes; if they ever drift from the export, the export
12
12
  wins.
13
13
 
@@ -1136,7 +1136,7 @@
1136
1136
 
1137
1137
  function _candidateLabel(el) {
1138
1138
  /* Best-effort human label for a DOM element. Used in
1139
- candidates[].label so voice/asistive can re-prompt. */
1139
+ candidates[].label so voice/assistive can re-prompt. */
1140
1140
  if (!el) return '';
1141
1141
  const al = el.getAttribute && el.getAttribute('aria-label');
1142
1142
  if (al) return String(al).trim();
@@ -2362,11 +2362,34 @@
2362
2362
  fields[], tabs[], kpis[], rows.cells[], breadcrumbs[], etc. */
2363
2363
  function _collectManifestIds(m) {
2364
2364
  const out = [];
2365
+ /* v2.5 fix (audit N-33): the CANONICAL manifest shape is
2366
+ `elements: [{ id, role, ... }]` -- that is what section 4
2367
+ documents, what every demo ships and what the rest of this
2368
+ runtime reads (see _capabilityFor, which walks
2369
+ m.elements.concat(m.tabs) by `.id`). This collector used to
2370
+ read ONLY the legacy groups below, keyed by `nac_id`, so for
2371
+ a manifest written the documented way it returned an empty
2372
+ list. Everything built on top went quietly wrong in the same
2373
+ direction: validate_global() reported total_ids = 0, called
2374
+ every declared element an orphan, could never report a
2375
+ duplicate, an unmounted id or a convention violation, and
2376
+ still answered ok = true. A validator that cannot see the
2377
+ manifest is not a lenient validator, it is a green light
2378
+ with nothing behind it. Both shapes are read now; the legacy
2379
+ groups stay because manifests in the wild still use them. */
2380
+ const elems = (m && m.elements) || [];
2381
+ elems.forEach(function (e) {
2382
+ if (e && e.id) out.push(String(e.id));
2383
+ });
2365
2384
  const groups = ['actions', 'fields', 'tabs', 'kpis', 'charts'];
2366
2385
  groups.forEach(function (g) {
2367
2386
  const arr = (m && m[g]) || [];
2368
2387
  arr.forEach(function (x) {
2388
+ /* tabs are declared with `.id` in the canonical shape and
2389
+ with `.nac_id` in the legacy one; take whichever is there
2390
+ instead of choosing a winner. */
2369
2391
  if (x && x.nac_id) out.push(String(x.nac_id));
2392
+ else if (x && x.id) out.push(String(x.id));
2370
2393
  });
2371
2394
  });
2372
2395
  if (m && m.rows && Array.isArray(m.rows.cells)) {
@@ -2383,7 +2406,14 @@
2383
2406
  }
2384
2407
  });
2385
2408
  }
2386
- return out;
2409
+ /* Unique: an id declared in two shapes of the SAME manifest is one
2410
+ id, not a cross-plugin duplicate. */
2411
+ const seen = Object.create(null);
2412
+ return out.filter(function (id) {
2413
+ if (seen[id]) return false;
2414
+ seen[id] = true;
2415
+ return true;
2416
+ });
2387
2417
  }
2388
2418
 
2389
2419
  function unregister(slug) {
@@ -3488,23 +3518,45 @@
3488
3518
  _focusElement(el);
3489
3519
  const ft = el.getAttribute('data-nac-field-type');
3490
3520
 
3521
+ /* The native property setter, or null when this host has no such
3522
+ constructor (audit N-44).
3523
+
3524
+ Every call site below already had a fallback -- `el.value = v`
3525
+ when the descriptor has no setter -- and the fallback was
3526
+ UNREACHABLE in the only environment it was written for. The guard
3527
+ tested the descriptor and the expression reached through
3528
+ `window.HTMLInputElement.prototype` to produce it, so on a host
3529
+ with a partial DOM (a test shim, an SSR or headless context --
3530
+ the paths this runtime claims to support) fill() threw
3531
+ `Cannot read properties of undefined (reading 'prototype')`
3532
+ before any fallback could run. Worse than the crash: the thrown
3533
+ value is a raw TypeError with no `code`, so a caller relying on
3534
+ the error contract gets nothing it can branch on.
3535
+
3536
+ A real browser is unaffected: the constructors always exist,
3537
+ the descriptor is found, and the native setter is used exactly
3538
+ as before -- which is what keeps React's controlled inputs
3539
+ working. */
3540
+ const _nativeSetter = function (ctorName, prop) {
3541
+ var ctor = (typeof window !== 'undefined') ? window[ctorName] : undefined;
3542
+ if (!ctor || !ctor.prototype) return null;
3543
+ var d = Object.getOwnPropertyDescriptor(ctor.prototype, prop);
3544
+ return (d && d.set) ? d.set : null;
3545
+ };
3546
+
3491
3547
  if (ft === 'checkbox' || ft === 'radio') {
3492
3548
  /* React tracks `checked` similarly to `value`; use the native
3493
3549
  setter so controlled checkboxes/radios update state. */
3494
- var nativeCheckedSetter = Object.getOwnPropertyDescriptor(
3495
- window.HTMLInputElement.prototype, 'checked'
3496
- );
3497
- if (nativeCheckedSetter && nativeCheckedSetter.set) {
3498
- nativeCheckedSetter.set.call(el, !!value);
3550
+ var nativeCheckedSetter = _nativeSetter('HTMLInputElement', 'checked');
3551
+ if (nativeCheckedSetter) {
3552
+ nativeCheckedSetter.call(el, !!value);
3499
3553
  } else {
3500
3554
  el.checked = !!value;
3501
3555
  }
3502
3556
  } else if (el.tagName === 'SELECT') {
3503
- var nativeSelectSetter = Object.getOwnPropertyDescriptor(
3504
- window.HTMLSelectElement.prototype, 'value'
3505
- );
3506
- if (nativeSelectSetter && nativeSelectSetter.set) {
3507
- nativeSelectSetter.set.call(el, String(value));
3557
+ var nativeSelectSetter = _nativeSetter('HTMLSelectElement', 'value');
3558
+ if (nativeSelectSetter) {
3559
+ nativeSelectSetter.call(el, String(value));
3508
3560
  } else {
3509
3561
  el.value = String(value);
3510
3562
  }
@@ -3516,13 +3568,13 @@
3516
3568
  tracks the original property setter on HTMLInputElement.prototype.
3517
3569
  Use the native setter so React's onChange receives the new value
3518
3570
  and updates its state. Works on plain DOM inputs unchanged. */
3519
- var proto = (el.tagName === 'TEXTAREA')
3520
- ? window.HTMLTextAreaElement.prototype
3521
- : window.HTMLInputElement.prototype;
3522
- var nativeValueSetter = Object.getOwnPropertyDescriptor(proto, 'value');
3571
+ var nativeValueSetter = _nativeSetter(
3572
+ (el.tagName === 'TEXTAREA') ? 'HTMLTextAreaElement' : 'HTMLInputElement',
3573
+ 'value'
3574
+ );
3523
3575
  var newVal = String(value == null ? '' : value);
3524
- if (nativeValueSetter && nativeValueSetter.set) {
3525
- nativeValueSetter.set.call(el, newVal);
3576
+ if (nativeValueSetter) {
3577
+ nativeValueSetter.call(el, newVal);
3526
3578
  } else {
3527
3579
  el.value = newVal;
3528
3580
  }
@@ -4629,16 +4681,36 @@
4629
4681
  DOM that belong to no manifest?" The per-plugin validate(slug)
4630
4682
  cannot see across boundaries; this one can.
4631
4683
 
4632
- Returns:
4684
+ Returns an OBJECT OF NAMED BUCKETS -- not a flat array of
4685
+ findings. Every item of every bucket carries `code` and
4686
+ `severity` since 2.5.0 (audit N-14), so a CI integration can
4687
+ gate on a code without parsing a message:
4633
4688
  {
4634
4689
  ok: boolean,
4635
- duplicates: [{nac_id, plugins:[...]}], // same id in 2+ manifests
4636
- orphans: [{nac_id, in_dom:true, in_manifest:false, plugin_root:?}],
4637
- unmounted: [{nac_id, in_manifest:true, in_dom:false, plugin}],
4638
- convention_violations: [{nac_id, plugin}], // nac_id missing 'plugin.' prefix
4690
+ has_errors: boolean,
4691
+ duplicates: [{code nac_id_duplicate_across_plugins,
4692
+ severity error, nac_id, plugins:[...]}],
4693
+ orphans: [{code nac_id_orphan_in_dom, severity warn,
4694
+ nac_id, in_dom:true, in_manifest:false,
4695
+ plugin_root:?}],
4696
+ unmounted: [{code nac_id_declared_not_mounted,
4697
+ severity warn, nac_id, in_manifest:true,
4698
+ in_dom:false, plugin}],
4699
+ convention_violations:
4700
+ [{code nac_id_missing_plugin_prefix,
4701
+ severity warn, nac_id, plugin, hint}],
4702
+ plugin_instance_violations:
4703
+ [{code duplicate_plugin_no_instance_id,
4704
+ severity error, slug, ...}],
4705
+ tolerated: [{kind, nac_id, until, original}],
4639
4706
  plugin_count, total_ids,
4640
4707
  timestamp
4641
4708
  }
4709
+ The five codes are published, with their severity and what to do
4710
+ about each, in api/latest/findings.json. (The code names above are
4711
+ written unquoted on purpose: the catalogue generator greps the
4712
+ emission shape out of this file, and a comment is not an
4713
+ emission.)
4642
4714
 
4643
4715
  A NAC-3 codebase that wants drift to be a CI blocker should run
4644
4716
  this in addition to the per-plugin validate(slug) loop. */
@@ -4677,6 +4749,13 @@
4677
4749
  ids.forEach(function (id) {
4678
4750
  if (id.indexOf(slug + '.') !== 0 && id !== slug) {
4679
4751
  out.convention_violations.push({
4752
+ /* v2.5 / audit N-14: every finding of this validator carries
4753
+ a code from the published catalogue, so section 12 promise
4754
+ 4 ("the validate_global finding codes will not be reused")
4755
+ covers a real set instead of an empty one. The code is the
4756
+ stable identity; the message is not. */
4757
+ code: 'nac_id_missing_plugin_prefix',
4758
+ severity: 'warn',
4680
4759
  nac_id: id, plugin: slug,
4681
4760
  hint: 'expected prefix "' + slug + '."',
4682
4761
  });
@@ -4688,7 +4767,11 @@
4688
4767
  /* Duplicates: any id that appears in 2+ manifests. */
4689
4768
  for (const id in idIndex) {
4690
4769
  if (idIndex[id].length >= 2) {
4691
- out.duplicates.push({ nac_id: id, plugins: idIndex[id].slice() });
4770
+ out.duplicates.push({
4771
+ code: 'nac_id_duplicate_across_plugins',
4772
+ severity: 'error',
4773
+ nac_id: id, plugins: idIndex[id].slice(),
4774
+ });
4692
4775
  }
4693
4776
  }
4694
4777
 
@@ -4709,6 +4792,8 @@
4709
4792
  severity for the caller to decide. */
4710
4793
  const root = el.closest('[data-nac-plugin]');
4711
4794
  out.orphans.push({
4795
+ code: 'nac_id_orphan_in_dom',
4796
+ severity: 'warn',
4712
4797
  nac_id: id,
4713
4798
  in_dom: true,
4714
4799
  in_manifest: false,
@@ -4722,6 +4807,8 @@
4722
4807
  for (const id in idIndex) {
4723
4808
  if (!inDom[id]) {
4724
4809
  out.unmounted.push({
4810
+ code: 'nac_id_declared_not_mounted',
4811
+ severity: 'warn',
4725
4812
  nac_id: id, in_manifest: true, in_dom: false,
4726
4813
  plugin: idIndex[id][0],
4727
4814
  });
@@ -7590,11 +7677,251 @@
7590
7677
  }
7591
7678
  }
7592
7679
 
7680
+ /* ================================================================
7681
+ v2.5 Block C -- RFC V25-03: assistive labels (narrate)
7682
+ ================================================================
7683
+
7684
+ NAC.narrate(plugin, nac_id) -> string
7685
+ Canonical human-readable label for any nac_id in the plugin's
7686
+ DOM. Priority order:
7687
+ 1. aria-label (a11y-first)
7688
+ 2. visible text (the human reading the chrome)
7689
+ 3. data-nac-label (author override)
7690
+ 4. nac_id (worst case)
7691
+
7692
+ For elements where the visible text leaks child-interactive
7693
+ content (eg a button containing an icon and a label), narrate
7694
+ prefers the FIRST text node directly under the element so the
7695
+ spoken output stays focused.
7696
+
7697
+ Returns null only if the element cannot be found (unknown
7698
+ nac_id or unknown plugin). Empty/whitespace labels collapse to
7699
+ the next priority tier. */
7700
+
7701
+ function _v25c_visibleText(el) {
7702
+ if (!el) return '';
7703
+ /* Collect text directly under el, excluding nested elements that
7704
+ are themselves nac-addressable (those have their own narrate
7705
+ resolution). */
7706
+ let out = '';
7707
+ for (let n = el.firstChild; n; n = n.nextSibling) {
7708
+ if (n.nodeType === 3 /* TEXT_NODE */) {
7709
+ out += n.nodeValue || '';
7710
+ } else if (n.nodeType === 1 /* ELEMENT_NODE */) {
7711
+ /* Skip nested nac-addressable subtrees -- they have their
7712
+ own label. */
7713
+ if (n.getAttribute && n.getAttribute('data-nac-id')) continue;
7714
+ /* Recurse into non-addressable children (typical: icon
7715
+ <span> + text). */
7716
+ out += _v25c_visibleText(n);
7717
+ }
7718
+ }
7719
+ return out.replace(/\s+/g, ' ').trim();
7720
+ }
7721
+
7722
+ function narrate(plugin, nac_id) {
7723
+ if (typeof nac_id !== 'string' || !nac_id) return null;
7724
+ /* Scope by plugin if provided -- look only inside [data-nac-plugin=plugin]
7725
+ subtree. If plugin is omitted, fall back to global search. */
7726
+ let root = document;
7727
+ if (plugin) {
7728
+ const pluginRoot = document.querySelector('[data-nac-plugin="' + plugin + '"]');
7729
+ if (!pluginRoot) return null;
7730
+ root = pluginRoot;
7731
+ }
7732
+ /* Use attribute selector with CSS-safe escape via JSON.stringify
7733
+ to avoid injection when nac_id contains weird chars. */
7734
+ const safeId = '"' + String(nac_id).replace(/["\\]/g, '\\$&') + '"';
7735
+ const el = root.querySelector('[data-nac-id=' + safeId + ']');
7736
+ if (!el) return null;
7737
+ /* 1. aria-label */
7738
+ const aria = el.getAttribute('aria-label');
7739
+ if (aria && aria.trim()) return aria.trim();
7740
+ /* 2. visible text (direct + nested non-addressable) */
7741
+ const vis = _v25c_visibleText(el);
7742
+ if (vis) return vis;
7743
+ /* 3. data-nac-label */
7744
+ const explicit = el.getAttribute('data-nac-label');
7745
+ if (explicit && explicit.trim()) return explicit.trim();
7746
+ /* 4. nac_id fallback */
7747
+ return nac_id;
7748
+ }
7749
+
7750
+ /* ================================================================
7751
+ v2.5 Block B -- RFC V25-02: tree navigation
7752
+ ================================================================
7753
+
7754
+ NAC.context(plugin) -> { breadcrumb: [{nac_id, label}, ...] }
7755
+ Walks up from document.activeElement through ancestor nac-id
7756
+ elements within the plugin subtree. Empty array when nothing
7757
+ focused inside the plugin.
7758
+
7759
+ NAC.tree(plugin, rootId?) -> [{nac_id, label, opens?, leaf?}, ...]
7760
+ Enumerates the IMMEDIATE addressable children of rootId (or the
7761
+ plugin root when rootId is omitted). "Immediate" means: there
7762
+ are no other nac-id elements between them and the start. Each
7763
+ entry reports the data-nac-opens target slug (if any) and a
7764
+ boolean leaf flag (data-nac-leaf attribute present).
7765
+
7766
+ Both functions delegate label resolution to narrate(). */
7767
+
7768
+ function _v25b_pluginRoot(plugin) {
7769
+ if (!plugin) return null;
7770
+ return document.querySelector('[data-nac-plugin="' + plugin + '"]');
7771
+ }
7772
+
7773
+ function context(plugin) {
7774
+ const out = { breadcrumb: [] };
7775
+ const root = _v25b_pluginRoot(plugin);
7776
+ if (!root) return out;
7777
+ const active = document.activeElement;
7778
+ if (!active || !root.contains(active)) return out;
7779
+ /* Walk up; collect each ancestor that owns a data-nac-id. Stop
7780
+ at the plugin root inclusive (root itself may not carry a
7781
+ nac-id -- in that case we just stop there). */
7782
+ let cur = active;
7783
+ while (cur && cur !== root.parentElement) {
7784
+ const id = cur.getAttribute && cur.getAttribute('data-nac-id');
7785
+ if (id) {
7786
+ out.breadcrumb.unshift({ nac_id: id, label: narrate(plugin, id) });
7787
+ }
7788
+ if (cur === root) break;
7789
+ cur = cur.parentElement;
7790
+ }
7791
+ return out;
7792
+ }
7793
+
7794
+ function _v25b_isImmediate(start, node) {
7795
+ /* True if `node` has no OTHER nac-id ancestor between itself and
7796
+ `start`. Excludes node === start and ancestors above start. */
7797
+ let p = node.parentElement;
7798
+ while (p && p !== start) {
7799
+ if (p.getAttribute && p.getAttribute('data-nac-id')) return false;
7800
+ p = p.parentElement;
7801
+ }
7802
+ return true;
7803
+ }
7804
+
7805
+ /* ================================================================
7806
+ v2.5 Block D -- RFC V25-04: effect detection (expect + diff)
7807
+ ================================================================
7808
+
7809
+ NAC.expect(plugin, statePath, value, opts?) -> Promise
7810
+ Polls NAC.read(plugin, statePath) until the returned value
7811
+ satisfies the comparator (default ===) or the timeout fires.
7812
+ Resolves with the resolved value on match.
7813
+ Rejects with NacError('timeout', ...) on deadline.
7814
+ Read failures are retried until the deadline (treated as
7815
+ "the state is not yet observable").
7816
+
7817
+ opts:
7818
+ timeout_ms default 5000
7819
+ poll_ms default 100
7820
+ comparator default (cur, want) => cur === want
7821
+ receives (current, expected) and returns boolean
7822
+
7823
+ NAC.diff(plugin, statePath, actionFn) -> Promise<{before, after, changed}>
7824
+ Reads state, awaits actionFn(), reads state again, returns
7825
+ both snapshots + a `changed` boolean (JSON-stringify compare).
7826
+ Read failures collapse to undefined and changed is computed
7827
+ on the stringified pair (so undefined vs value still flags).
7828
+
7829
+ Both delegate to NAC.read() so they inherit V25-01's full
7830
+ fallback-chain semantics for free. */
7831
+
7832
+ function expect(plugin, statePath, value, opts) {
7833
+ opts = opts || {};
7834
+ const timeout = (typeof opts.timeout_ms === 'number') ? opts.timeout_ms : 5000;
7835
+ const pollMs = (typeof opts.poll_ms === 'number') ? opts.poll_ms : 100;
7836
+ const cmp = (typeof opts.comparator === 'function')
7837
+ ? opts.comparator
7838
+ : function (cur, want) { return cur === want; };
7839
+ const deadline = Date.now() + timeout;
7840
+ return new Promise(function (resolve, reject) {
7841
+ function tick() {
7842
+ read(plugin, statePath).then(function (cur) {
7843
+ let matches = false;
7844
+ try { matches = !!cmp(cur, value); }
7845
+ catch (_) { matches = false; }
7846
+ if (matches) { resolve(cur); return; }
7847
+ if (Date.now() >= deadline) {
7848
+ reject(_v25_buildNacError('timeout',
7849
+ 'NAC.expect: state "' + statePath + '" did not match within ' +
7850
+ timeout + 'ms (last value: ' + JSON.stringify(cur) + ')'));
7851
+ return;
7852
+ }
7853
+ setTimeout(tick, pollMs);
7854
+ }, function (_err) {
7855
+ if (Date.now() >= deadline) {
7856
+ reject(_v25_buildNacError('timeout',
7857
+ 'NAC.expect: state "' + statePath + '" unreadable + timeout'));
7858
+ return;
7859
+ }
7860
+ setTimeout(tick, pollMs);
7861
+ });
7862
+ }
7863
+ tick();
7864
+ });
7865
+ }
7866
+
7867
+ function diff(plugin, statePath, actionFn) {
7868
+ function safeRead() {
7869
+ return read(plugin, statePath).then(
7870
+ function (v) { return v; },
7871
+ function () { return undefined; }
7872
+ );
7873
+ }
7874
+ return safeRead().then(function (before) {
7875
+ const act = (typeof actionFn === 'function')
7876
+ ? Promise.resolve(actionFn())
7877
+ : Promise.resolve();
7878
+ return act.then(function () {
7879
+ return safeRead().then(function (after) {
7880
+ let changed;
7881
+ try {
7882
+ changed = JSON.stringify(before) !== JSON.stringify(after);
7883
+ } catch (_) {
7884
+ changed = before !== after;
7885
+ }
7886
+ return { before: before, after: after, changed: changed };
7887
+ });
7888
+ });
7889
+ });
7890
+ }
7891
+
7892
+ function tree(plugin, rootId) {
7893
+ const pluginRoot = _v25b_pluginRoot(plugin);
7894
+ if (!pluginRoot) return [];
7895
+ let start = pluginRoot;
7896
+ if (rootId) {
7897
+ const safeId = '"' + String(rootId).replace(/["\\]/g, '\\$&') + '"';
7898
+ const found = pluginRoot.querySelector('[data-nac-id=' + safeId + ']');
7899
+ if (!found) return [];
7900
+ start = found;
7901
+ }
7902
+ const candidates = start.querySelectorAll('[data-nac-id]');
7903
+ const out = [];
7904
+ for (let i = 0; i < candidates.length; i++) {
7905
+ const k = candidates[i];
7906
+ if (!_v25b_isImmediate(start, k)) continue;
7907
+ const id = k.getAttribute('data-nac-id');
7908
+ const entry = {
7909
+ nac_id: id,
7910
+ label: narrate(plugin, id),
7911
+ };
7912
+ const opens = k.getAttribute('data-nac-opens');
7913
+ if (opens) entry.opens = opens;
7914
+ if (k.hasAttribute('data-nac-leaf')) entry.leaf = true;
7915
+ out.push(entry);
7916
+ }
7917
+ return out;
7918
+ }
7919
+
7593
7920
  /* ---------- Install -------------------------------------------- */
7594
7921
 
7595
7922
  global.NAC = {
7596
7923
  __nac_v1_installed: true,
7597
- version: '2.5.0-alpha.4',
7924
+ version: '2.5.0',
7598
7925
  spec_version: '2.5',
7599
7926
  /* v2.2.0 (V22-01) -- strict validation toggle. When true,
7600
7927
  NAC.register throws on findings (manifest_role_unknown,
@@ -7845,6 +8172,25 @@
7845
8172
  read: read,
7846
8173
  subscribe: subscribe,
7847
8174
  unsubscribe: unsubscribe,
8175
+ /* v2.5 Block C -- assistive labels (SPEC.md sec 17 / RFC V25-03).
8176
+ Canonical human-readable label resolution for screen readers,
8177
+ TTS, voice flows, audit logs. Priority order: aria-label >
8178
+ visible text > data-nac-label > nac_id fallback. */
8179
+ narrate: narrate,
8180
+ /* v2.5 Block B -- tree navigation (SPEC.md sec 16 / RFC V25-02).
8181
+ context(plugin) returns the focused node's breadcrumb;
8182
+ tree(plugin, rootId?) enumerates navigable children.
8183
+ data-nac-opens declares parent->child relationships; data-nac-leaf
8184
+ marks terminals. Companion to narrate for chrome-driven walks. */
8185
+ context: context,
8186
+ tree: tree,
8187
+ /* v2.5 Block D -- effect detection (SPEC.md sec 18 / RFC V25-04).
8188
+ Closes the "silent damage" gap for assistive callers: the agent
8189
+ confirms the EFFECT of an action, not just that the command was
8190
+ emitted. expect() polls until a state matches; diff() snapshots
8191
+ around an action. Both compose with NAC.read() / V25-01 surface. */
8192
+ expect: expect,
8193
+ diff: diff,
7848
8194
  };
7849
8195
 
7850
8196
  /* v2.2.1: guard browser-only init so this module is importable in