@nac3/runtime 2.3.1 → 2.4.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/SPEC.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # NAC3 -- Native Agent Contract
2
2
 
3
- **Version:** 2.3.0
4
- **Status:** Stable (npm `@nac3/runtime@2.3.0`)
5
- **Benchmark:** 600 runs across 5 models x 3 protocols -- [results](./benchmark/)
3
+ **Version:** 2.4.0 (stable; zero silent damage via strict resolution + disambiguation contract)
4
+ **Status:** v2.4.0 stable -- supersedes 2.3.x
6
5
  **License:** Apache-2.0
7
- **Editor:** Yujin (yujin.app)
8
- **RFCs in flight:** see [/rfcs/](./rfcs/) for V24-04 (snapshot versioning, enforcement opt-in in 2.3.0) and V24-05 (authority, draft for 2.4).
6
+ **Editor:** Yujin (rpaforce.com)
9
7
 
10
8
  ---
11
9
 
@@ -71,10 +69,9 @@ Every agent-resolvable element carries `data-nac-id`. The id is:
71
69
  - **A dotted path** (e.g. `deals.list.row.42.actions.delete`).
72
70
  Dots separate semantic levels; the runtime does not interpret
73
71
  them, but humans and LLMs do.
74
- - **Globally unique within a `(data-nac-plugin, data-nac-plugin-id)`
75
- instance scope.** Two different plugins MAY share an id; the
76
- runtime resolves by `(plugin, plugin_instance_id, id)` pair.
77
- See sec 7.4 for the plugin slug uniqueness contract.
72
+ - **Globally unique within a `data-nac-plugin` scope.** Two
73
+ different plugins MAY share an id; the runtime resolves by
74
+ `(plugin, id)` pair.
78
75
  - **Stable across re-renders.** Frameworks that produce a new id
79
76
  per render (random hashes, instance counters) break the contract.
80
77
  - **Stable across UI redesigns.** A button moves from the toolbar
@@ -225,9 +222,8 @@ NAC-3 callable verbs:
225
222
  Esc closes (cancel). Ctrl/Cmd+Enter saves. Click on overlay
226
223
  backdrop cancels.
227
224
 
228
- The v2.3 runtime ships a working reference impl and the contract is
229
- stable. The 600-run benchmark exercises `ai_correct_syntax` + `save`
230
- under the V23_EDITOR_fix_monitor task.
225
+ Spec sec 13 will formalise the contract in v2.3; the v2.2 runtime
226
+ ships a working reference impl so adopters can wire it today.
231
227
  Available on any field via:
232
228
 
233
229
  ```js
@@ -236,11 +232,444 @@ NAC.edit_field('invoice.client_name');
236
232
  NAC.click_by_verb('myplugin', 'edit_field', { nac_id: 'invoice.client_name' });
237
233
  ```
238
234
 
239
- ### 5.1.2 Strict validation flag (v2.2)
235
+ ### 5.1.4 Action payload + invoke (v2.3)
240
236
 
241
- `NAC.STRICT_VALIDATION` (boolean, default `false` in v2.2). When
242
- `true`, `NAC.register()` throws an `Error` with `code='strict_validation'`
243
- and a `findings` array on any of:
237
+ NAC v2.2 actions are click-and-go: an agent triggers `NAC.click(id)`
238
+ or `NAC.click_by_verb(plugin, verb)` and the host runs whatever it
239
+ does. This works for verb-and-state actions (`save`, `cancel`,
240
+ `submit`, `delete`) but collapses when an action needs **data**
241
+ from the agent -- `utter(text)`, `search(query)`,
242
+ `send_message(body)`, `upload(file)`, `schedule(date)`,
243
+ `translate(text, target_lang)`. The host has no way to receive
244
+ the agent's payload via a synthetic click.
245
+
246
+ v2.3 closes this gap. The contract is additive: click-style
247
+ verbs continue to work unchanged.
248
+
249
+ ```ts
250
+ NAC.invoke(action_id: string, payload: object, opts?: { timeout?: number })
251
+ : Promise<{ok: true, request_id: string, ack: object|null}>
252
+
253
+ NAC.utter(action_id: string,
254
+ opts: { text: string, lang?: string, voice?: string, metadata?: object })
255
+ : Promise<{ok: true, request_id: string, ack: object|null}>
256
+ ```
257
+
258
+ `NAC.invoke` dispatches a `nac:action:requested` `CustomEvent`
259
+ on the host element (bubbles to document) with:
260
+
261
+ ```ts
262
+ detail: {
263
+ action_id: string, // canonical nac_id of the host element
264
+ verb: string, // payload.verb || el's data-nac-action
265
+ payload: object, // arbitrary, action-specific
266
+ plugin: string|null,
267
+ request_id: string, // correlation token assigned by the runtime
268
+ ts: number, // Date.now()
269
+ }
270
+ ```
271
+
272
+ The host listens for `nac:action:requested`, processes the
273
+ payload, and emits `nac:action:succeeded` (or `nac:action:failed`)
274
+ with the same `request_id` in the detail. The runtime correlates
275
+ by `request_id` and resolves the agent's Promise.
276
+
277
+ Default timeout is **30 seconds** (vs 5 s for click). Override
278
+ with `opts.timeout`. On timeout, the Promise rejects with
279
+ `NacError('timeout', ...)`. As with click, a timeout means real
280
+ failure: callers MUST treat it as such unless they have side-
281
+ effect proof via another channel.
282
+
283
+ `NAC.utter(id, opts)` is the ergonomic shortcut for the most
284
+ common payload-bearing verb. It is equivalent to:
285
+
286
+ ```js
287
+ NAC.invoke(id, { verb: 'utter', text: opts.text, lang: opts.lang });
288
+ ```
289
+
290
+ #### Manifest declaration
291
+
292
+ A payload-bearing action declares its payload schema in the
293
+ manifest entry for traceability and tooling:
294
+
295
+ ```js
296
+ NAC.register({
297
+ plugin_slug: 'atlas_pro_ad',
298
+ version: '2.1.0',
299
+ nac_version: '2.3',
300
+ elements: [
301
+ { id: 'atlas_pro_ad.mic', role: 'action',
302
+ actions: [
303
+ { verb: 'listen' },
304
+ { verb: 'utter',
305
+ payload_schema: {
306
+ text: { type: 'string', required: true, max: 4000 },
307
+ lang: { type: 'string',
308
+ enum: ['en','es','pt','fr','it','de','ja','zh','hi','ar'] }
309
+ },
310
+ label_i18n: { es:'Decir', en:'Utter', /* ... 10 locales */ } }
311
+ ],
312
+ label_i18n: { /* ... */ } }
313
+ ]
314
+ });
315
+ ```
316
+
317
+ `payload_schema` is informational in v2.3 stable. Agents MAY
318
+ validate before sending; runtimes MAY enforce it when
319
+ `STRICT_VALIDATION` is `true`. Schemas are intentionally simple
320
+ (JSON-Schema-shaped subset) so a runtime can validate without
321
+ shipping a full JSON-Schema validator. v2.4 will formalise the
322
+ schema grammar and turn enforcement into a default.
323
+
324
+ #### Disabled-state semantics (v2.3 hotfix from alpha.2)
325
+
326
+ `NAC.invoke` does NOT reject when the target element has
327
+ `disabled` or `aria-disabled='true'` set. The `disabled` HTML
328
+ attribute is a UX click guard; `invoke` is a logical
329
+ payload-bearing request, not a synthetic click. Hosts that need
330
+ to refuse an invoke based on UI state MUST do it in their
331
+ `nac:action:requested` listener and emit `nac:action:failed`
332
+ with a meaningful error code.
333
+
334
+ `NAC.click`, by contrast, STILL rejects on disabled elements
335
+ (click semantics preserved). Test coverage:
336
+ `packages/nac/test/v23-invoke.mjs` T7/T8/T9.
337
+
338
+ #### Conformance: hosts that support invoke MUST
339
+
340
+ 1. Declare `actions[].payload_schema` in the manifest entry.
341
+ 2. Listen for `nac:action:requested` (or use a generic listener
342
+ that filters by `detail.action_id` + `detail.verb`).
343
+ 3. Emit `nac:action:succeeded` -- with `detail.request_id`
344
+ echoed back -- after processing, or `nac:action:failed`
345
+ (with `detail.error` code) on failure.
346
+ 4. NEVER emit a `:succeeded` event with a `request_id` they did
347
+ not receive (prevents cross-talk between concurrent invocations).
348
+
349
+ Hosts that do NOT support invoke continue to operate normally
350
+ under `NAC.click()` and `NAC.click_by_verb()`. Agents that call
351
+ `NAC.invoke()` against a host without an `actions[].payload_schema`
352
+ entry will still receive a `request_id` but the runtime cannot
353
+ guarantee delivery; the timeout fires after 30 s.
354
+
355
+ #### Why this matters
356
+
357
+ The full agentic surface stops being "list of buttons" and
358
+ becomes "list of buttons + structured inputs". A voice ad becomes
359
+ NAC.invoke-able. A search bar becomes NAC.invoke-able. A
360
+ file upload becomes NAC.invoke-able. Same protocol, same
361
+ provenance, same ack semantics.
362
+
363
+ The first reference adopter is **Atlas Pro** -- its
364
+ `atlas_pro_ad.mic` element declares both `listen` (click-only,
365
+ existing) and `utter` (payload-bearing) verbs. The same
366
+ `/parse` + `/tts` conversational loop drives in either case;
367
+ agents that have STT call `listen`, agents that have their own
368
+ language model call `utter`.
369
+
370
+ #### Forward modalities (anticipated, no spec change required)
371
+
372
+ `invoke` is intentionally modality-agnostic so future input
373
+ families plug in without breaking the contract:
374
+
375
+ | Modality | Verb (sketch) | Payload (sketch) |
376
+ |----------|-----------------------|--------------------------------------------------|
377
+ | Text | `utter` | `{text, lang?}` |
378
+ | Search | `search` | `{query, scope?, limit?}` |
379
+ | File | `upload` | `{filename, mime, data_url \| stream_id}` |
380
+ | Image | `analyze_image` | `{image_url \| data_url, prompt?}` |
381
+ | Video | `analyze_stream` | `{stream_url, frame_window_ms?, return?}` |
382
+ | Schedule | `schedule` | `{datetime, duration_min, attendees?}` |
383
+ | Code | `apply_diff` | `{file_path, unified_diff}` |
384
+ | Voice | `transcribe` | `{audio_url \| data_url, lang?}` |
385
+
386
+ Each modality follows the same `nac:action:requested` ->
387
+ `nac:action:succeeded` / `:failed` event protocol, the same
388
+ `request_id` correlation, the same timeout semantics. The
389
+ runtime stays small; the verb vocabulary grows by convention
390
+ between hosts and agents. Ergonomic shortcuts (`NAC.utter`,
391
+ `NAC.search`, `NAC.watch`, etc.) can be added later without
392
+ re-spec because each is a thin wrapper over `invoke`.
393
+
394
+ ### 5.1.5 Shadow DOM resolution -- open roots (v2.3)
395
+
396
+ The runtime resolves `data-nac-id` references through open
397
+ shadow roots recursively. A page can mount Web Components
398
+ using `attachShadow({mode:'open'})`, place
399
+ `data-nac-*` attributes on elements inside the shadow tree,
400
+ and any NAC3 caller (`NAC.click`, `NAC.fill`, `NAC.invoke`,
401
+ etc.) resolves the target transparently.
402
+
403
+ #### Resolution algorithm
404
+
405
+ For a selector `S` (typically `[data-nac-id="..."]`) against a
406
+ root `R` (typically `document`):
407
+
408
+ 1. `R.querySelector(S)` -> if non-null, return immediately.
409
+ 2. For every descendant `el` of `R`:
410
+ - If `el.shadowRoot` is non-null (i.e. open shadow root):
411
+ recurse with `R := el.shadowRoot`, depth +1.
412
+ - Else if `el.nac3` is an object exposing a `query` method,
413
+ delegate (see sec 5.1.6).
414
+ 3. The recursion is **depth-capped at 10 levels**. Targets
415
+ deeper than 10 are unreachable; the caller receives
416
+ `code='not_found'`. The cap exists to prevent pathological
417
+ walks; in practice no production codebase nests more than
418
+ 3-4 shadow levels.
419
+ 4. The walk is breadth-of-DOM-order: siblings before nested
420
+ shadows. First match wins.
421
+
422
+ #### Event propagation
423
+
424
+ Events emitted by hosts inside shadow roots MUST set
425
+ `composed: true` for document-level listeners to receive them.
426
+ The NAC3 runtime emits all its own events with `composed:true`
427
+ already; host code that emits manual `nac:*` events is
428
+ responsible for the same. Without `composed:true` the event
429
+ stops at the shadow boundary and the runtime's correlation
430
+ machinery never sees it.
431
+
432
+ #### Author responsibility
433
+
434
+ The component author needs to:
435
+
436
+ 1. Place `data-nac-id`, `data-nac-role`, `data-nac-action` on
437
+ operable elements inside the shadow root.
438
+ 2. Set `composed:true` on any custom event the host emits to
439
+ signal a NAC3 contract (`nac:action:succeeded`,
440
+ `nac:field:changed`, etc.).
441
+ 3. Avoid `<slot>` for elements that need to be
442
+ shadow-isolated -- slotted nodes live in light DOM and are
443
+ resolved there instead.
444
+
445
+ No manifest hint or runtime opt-in is required for open shadow
446
+ roots; the resolution is automatic.
447
+
448
+ #### Reference implementation
449
+
450
+ The reference runtime exposes two internal helpers,
451
+ `_deepQuery(selector, root)` and
452
+ `_deepQueryAll(selector, root)`, that perform the walk. Public
453
+ helpers `NAC.click`, `NAC.fill`, `NAC.invoke`,
454
+ `NAC.describe`, etc. all go through the deep variants.
455
+
456
+ #### Demos and tests
457
+
458
+ - `example-v23-shadow-open.php` -- 1-, 2-, and 3-level nested
459
+ open shadow demos.
460
+ - `packages/nac/test/v23-shadow.mjs` T1-T3, T10 -- unit
461
+ coverage including depth cap.
462
+
463
+ ### 5.1.6 Shadow DOM resolution -- closed roots, voluntary exposure (v2.3)
464
+
465
+ Closed shadow roots (`attachShadow({mode:'closed'})`) are
466
+ opaque from outside the component author's code -- a browser
467
+ security boundary, not a NAC3 decision. NAC3 cannot reach
468
+ inside unless the component author voluntarily exposes a
469
+ queriable surface via the contract below.
470
+
471
+ #### The `el.nac3` interface contract
472
+
473
+ A custom element MAY expose an interface object on its host
474
+ via a getter named `nac3`:
475
+
476
+ ```ts
477
+ interface NAC3HostInterface {
478
+ query(selector: string): Element | null; // MANDATORY
479
+ queryAll(selector: string): Element[]; // RECOMMENDED
480
+ describe?(): Array<{ // OPTIONAL
481
+ id: string;
482
+ role: string;
483
+ action?: string;
484
+ label?: string;
485
+ }>;
486
+ }
487
+ ```
488
+
489
+ Components opt in by implementing the getter. Components that
490
+ do NOT opt in remain inaccessible to NAC3 callers (their
491
+ internals stay private, as the browser intends).
492
+
493
+ #### Resolution semantics
494
+
495
+ During `_deepQuery(selector)`, for every visited element `el`
496
+ with `el.shadowRoot === null`:
497
+
498
+ 1. If `typeof el.nac3 === 'object'` and `el.nac3.query` is a
499
+ function, the runtime calls `el.nac3.query(selector)`:
500
+ - Return value is an Element -> resolved.
501
+ - Return value is `null` -> not a match in this shadow.
502
+ - Return value is anything else -> emit
503
+ `nac:shadow_protocol_violation` (once per host) and skip.
504
+ - Throws -> emit `nac:shadow_blocked` (reason
505
+ `'exposure_threw'`, once per host) and skip.
506
+ 2. Else if `el.hasAttribute('data-nac-shadow') === true` and
507
+ the attribute value is `'closed'` AND there is no `nac3`
508
+ interface present, the runtime emits `nac:shadow_blocked`
509
+ (reason `'not_exposed'`, once per host). Author opt-in to
510
+ the "I am a deliberately closed component" debug signal.
511
+ 3. Else: the element is treated as a normal light-DOM
512
+ element with no shadow root.
513
+
514
+ #### Error event detail shapes
515
+
516
+ `nac:shadow_blocked` detail:
517
+
518
+ ```ts
519
+ {
520
+ host: Element, // the closed-shadow host
521
+ reason: 'exposure_threw' | 'not_exposed',
522
+ ts: number // Date.now()
523
+ }
524
+ ```
525
+
526
+ `nac:shadow_protocol_violation` detail:
527
+
528
+ ```ts
529
+ {
530
+ host: Element,
531
+ message: string, // diagnostic message
532
+ value_snapshot: string, // truncated value preview
533
+ ts: number
534
+ }
535
+ ```
536
+
537
+ Both events bubble (`bubbles: true`) and cross shadow
538
+ boundaries (`composed: true`). Dedup is per-host via a
539
+ WeakSet kept by the runtime; the same host emits each event
540
+ **at most once per page load**.
541
+
542
+ #### Why voluntary
543
+
544
+ The browser enforces closed-shadow opacity. Even if NAC3
545
+ defined a non-voluntary mechanism, the browser would prevent
546
+ it. Voluntary exposure puts the component author in full
547
+ control of what their public surface looks like for agents.
548
+
549
+ The cost is per-component opt-in; the benefit is that
550
+ NAC3-compliant agents work against design systems with closed
551
+ shadow components (Salesforce Lightning, some GitHub Primer
552
+ components, security-sensitive widgets) without per-component
553
+ adapter code.
554
+
555
+ #### Demos and tests
556
+
557
+ - `example-v23-shadow-closed.php` -- positive
558
+ (`<todo-card-closed-exposed>`) and negative
559
+ (`<todo-card-closed-blind>`) side-by-side with verdict
560
+ panels + live event log.
561
+ - `packages/nac/test/v23-shadow.mjs` T4-T9 -- unit coverage
562
+ for every error event family plus dedup semantics.
563
+ - `guides/SHADOW_DOM_CLOSED.md` -- authoring guide.
564
+
565
+ ### 5.1.7 Auth-aware capabilities (v2.3)
566
+
567
+ NAC3 v2.3 lets the manifest declare per-action capability
568
+ requirements that gate `NAC.click` and `NAC.invoke` before
569
+ dispatch. The agent receives a fast rejection
570
+ (`code='capability_required'`) instead of a round-trip that
571
+ fails server-side.
572
+
573
+ #### Manifest declaration
574
+
575
+ A capability requirement attaches at the element level or at
576
+ the verb level. Verb-level wins if both are present.
577
+
578
+ ```js
579
+ NAC.register({
580
+ plugin_slug: 'fin',
581
+ version: '1.0.0',
582
+ nac_version: '2.3',
583
+ elements: [
584
+ // Element-level (covers all verbs on this id).
585
+ { id: 'fin.invoice.delete', role: 'action',
586
+ requires_capability: 'finance.delete_invoice',
587
+ actions: [{ verb: 'delete' }] },
588
+
589
+ // Verb-level (more granular).
590
+ { id: 'fin.invoice.edit', role: 'action',
591
+ actions: [
592
+ { verb: 'edit',
593
+ requires_capability: 'finance.edit_invoice' },
594
+ { verb: 'view',
595
+ /* no capability -> always allowed */ }
596
+ ] },
597
+
598
+ // Array value: OR semantics.
599
+ // ("at least one of these capabilities matches")
600
+ { id: 'fin.invoice.approve', role: 'action',
601
+ requires_capability: ['finance.approve',
602
+ 'finance.admin'],
603
+ actions: [{ verb: 'approve' }] }
604
+ ]
605
+ });
606
+ ```
607
+
608
+ For AND semantics ("user needs ALL of these caps"), declare
609
+ each via separate gated actions or compose at the host level
610
+ in the `nac:action:requested` listener.
611
+
612
+ #### Public API
613
+
614
+ ```ts
615
+ NAC.setCapabilities(caps: string | string[] | null): void
616
+ NAC.grantCapability(cap: string): void
617
+ NAC.revokeCapability(cap: string): void
618
+ NAC.userCapabilities(): string[]
619
+ ```
620
+
621
+ `setCapabilities` replaces the entire set (use for login /
622
+ session refresh). `grantCapability` / `revokeCapability` are
623
+ incremental. `userCapabilities` returns a snapshot array.
624
+ `setCapabilities(null)` clears the set.
625
+
626
+ Hosts call these whenever the user's role changes. The set
627
+ lives in the runtime; no manifest reload is required.
628
+
629
+ #### Gate semantics
630
+
631
+ Before dispatch, `NAC.click(id)` and `NAC.invoke(id, payload)`
632
+ look up the matching manifest entry (element + verb), read
633
+ `requires_capability`, and call `_hasCapability`:
634
+
635
+ - No requirement declared -> allow.
636
+ - Requirement declared, current set satisfies it -> allow.
637
+ - Requirement declared, current set does NOT satisfy -> reject
638
+ with `NacError('capability_required', ...)` AND emit
639
+ `nac:command:rejected` with `detail.reason='capability_required'`.
640
+
641
+ The gate runs AFTER `not_found` / `disabled` / `hidden` checks
642
+ on `click` so the most specific failure surfaces. On `invoke`,
643
+ the gate runs before the request event fires (the host never
644
+ sees an unauthorised attempt).
645
+
646
+ #### Why this matters
647
+
648
+ Without the gate, an agent calling `NAC.click('finance.delete')`
649
+ either succeeds (no auth gate at all -> security hole) or
650
+ fails server-side with a 403 several seconds later. With the
651
+ gate, the agent learns synchronously that it lacks the
652
+ capability and can react appropriately (request a different
653
+ flow, ask for elevation, surface the constraint to the user).
654
+
655
+ This complements -- it does not replace -- server-side
656
+ authorisation. Hosts MUST still enforce permissions on the
657
+ server. The client gate is a UX optimisation and an
658
+ intent-level signal, not a security boundary.
659
+
660
+ #### Demos and tests
661
+
662
+ - `packages/nac/test/v23-capabilities.mjs` -- 17 assertions
663
+ covering set/get, grant/revoke, click gate, invoke gate,
664
+ verb-level vs element-level resolution, OR semantics,
665
+ null-clear, invalid-input rejection, regression for
666
+ unguarded actions.
667
+
668
+ ### 5.1.2 Strict validation flag (v2.2; default-flipped in v2.3)
669
+
670
+ `NAC.STRICT_VALIDATION` (boolean). When `true`, `NAC.register()`
671
+ throws an `Error` with `code='strict_validation'` and a
672
+ `findings` array on any of:
244
673
 
245
674
  - `manifest_role_unknown` -- entry's role outside the canonical set.
246
675
  - `tab_id_manifest_role_drift` -- id matches `^tab\.` but role
@@ -248,18 +677,38 @@ and a `findings` array on any of:
248
677
  - `manifest_dom_role_mismatch` -- mounted DOM element's
249
678
  `data-nac-role` differs from manifest entry's role.
250
679
 
251
- In v2.3 the default flips to `true`. In v3.0 the flag is removed
252
- (strict is the only mode).
680
+ **Default value:**
681
+
682
+ - **v2.2.x:** `false` (warning-only). Adopters needed a migration
683
+ window.
684
+ - **v2.3.x:** **`true`** (throwing). The migration window closed
685
+ with the v2.2 line. Adopters with drift-laden manifests opt
686
+ out by setting `NAC.STRICT_VALIDATION = false` BEFORE any
687
+ `register()` call.
688
+ - **v3.0:** flag removed (strict is the only mode).
689
+
690
+ See `guides/MIGRATION_v2.2_to_v2.3.md` for the playbook to clean
691
+ up drift findings.
253
692
 
254
693
  All async methods reject with `NacError` whose `code` is one of:
255
694
 
256
695
  - `not_found` -- the named element/role/verb is not in the DOM.
257
696
  - `invalid` -- argument shape is wrong.
697
+ - `disabled` -- element has `disabled` or `aria-disabled='true'`
698
+ (`NAC.click` only; `NAC.invoke` no longer checks per v2.3
699
+ hotfix, see sec 5.1.4).
700
+ - `hidden` -- element is offscreen / `aria-hidden='true'` /
701
+ zero-dimension.
702
+ - `capability_required` -- manifest declared
703
+ `requires_capability` and the current
704
+ `NAC.userCapabilities()` set does not satisfy it (v2.3, see
705
+ sec 5.1.7).
258
706
  - `timeout` -- side effect dispatched but the conformance ack
259
- event did not arrive within 5 seconds. **A timeout means real
260
- failure**: the handler may have hung, the ack was never wired,
261
- a network race occurred. Callers MUST treat timeout as failure
262
- unless they have proof of side effect via another channel.
707
+ event did not arrive within 5 seconds (30 seconds for
708
+ `invoke`). **A timeout means real failure**: the handler may
709
+ have hung, the ack was never wired, a network race occurred.
710
+ Callers MUST treat timeout as failure unless they have proof
711
+ of side effect via another channel.
263
712
 
264
713
  ### 5.2 Introspection
265
714
 
@@ -413,66 +862,6 @@ See `SECURITY.md` for the full threat model. Short version:
413
862
  - NAC3 does not protect against a malicious agent running with
414
863
  user-level access. Such an agent can do anything the user can.
415
864
 
416
- ### 7.4 Plugin slug uniqueness (v2.4)
417
-
418
- A `data-nac-plugin="<slug>"` attribute identifies a plugin
419
- **instance** in the DOM. The runtime resolves
420
- `(plugin, nac_id)` pairs against these scopes, so the host MUST
421
- guarantee unambiguous resolution.
422
-
423
- **Rules.**
424
-
425
- 1. A given plugin slug MAY appear on more than one DOM root
426
- simultaneously (a "list view + side panel" combo for the same
427
- plugin family, a topbar mirror of an action that also lives in
428
- the body, etc).
429
- 2. **When the slug appears more than once, every root carrying it
430
- MUST also carry a unique `data-nac-plugin-id` attribute.** The
431
- pair `(data-nac-plugin, data-nac-plugin-id)` is the canonical
432
- instance key.
433
- 3. A single-root slug MAY omit `data-nac-plugin-id`; in that case
434
- `(slug, null)` is the instance key.
435
-
436
- **Runtime enforcement (v2.4).**
437
-
438
- - The constructor `NAC.register(manifest)` rejects the call
439
- synchronously with `NacError('duplicate_plugin_no_instance_id',
440
- ...)` when the DOM already contains multiple roots with the
441
- registered slug and any of them omits / duplicates
442
- `data-nac-plugin-id`.
443
- - A boot-time pass (`nac:dom-ready` listener installed by the
444
- runtime) performs the same check across every `[data-nac-plugin]`
445
- root in the document. On the first violation it dispatches
446
- `nac:fatal` with `code='duplicate_plugin_no_instance_id'`,
447
- inserts a visible red banner at the top of `<body>`, and
448
- throws. The runtime then refuses every subsequent
449
- `describe`/`click`/`click_by_verb`/`tab` call.
450
- - `NAC.click_by_verb` resolves verbs against the manifest first.
451
- When the manifest does not declare a top-level `actions[]` and
452
- the runtime falls back to DOM scanning, the scan iterates
453
- **every** `[data-nac-plugin="<slug>"]` root (not just the
454
- first), matching the first descendant `[data-nac-action="<verb>"]`
455
- it finds.
456
- - `NAC.validate_global()` continues to emit
457
- `duplicate_plugin_no_instance_id` as a structured finding for CI
458
- pipelines that prefer non-fatal reporting.
459
-
460
- **Migration from v2.3.**
461
-
462
- The boot-time throw is enabled by default in v2.4. Authors who
463
- need a one-release migration window can set
464
- `NAC.HARD_DEDUP = false` before the runtime's
465
- `DOMContentLoaded` listener fires. The flag is removed in v2.5.
466
-
467
- **Why "throw" not "warn".**
468
-
469
- Multiple roots sharing a slug without instance ids make every
470
- `(plugin, nac_id)` lookup first-match-wins by document order.
471
- That is non-deterministic across DOM rearrangements (drag-drop
472
- sorts, conditional render order, framework re-mounts) and the
473
- agent has no way to know which root won. v2.3 surfaced this only
474
- through opt-in lint; v2.4 makes it a build-time gate.
475
-
476
865
  ---
477
866
 
478
867
  ## 8. Conformance levels
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // NAC CLI v2.2.1
2
+ // NAC CLI v2.3.0-alpha.2
3
3
  // Usage:
4
4
  // nac validate <url-or-dir> [--severity=error|warn|info]
5
5
  // nac --version
@@ -18,7 +18,7 @@ const args = process.argv.slice(2);
18
18
  const cmd = args[0];
19
19
 
20
20
  function showHelp() {
21
- console.log('NAC CLI v2.2.1');
21
+ console.log('NAC CLI v2.3.0-alpha.2');
22
22
  console.log('');
23
23
  console.log('Usage:');
24
24
  console.log(' nac validate <url-or-dir> [--severity=error|warn|info]');
@@ -27,7 +27,7 @@ function showHelp() {
27
27
  }
28
28
 
29
29
  function showVersion() {
30
- console.log('@nac3/runtime CLI 2.2.1 (Native Agent Contract v2.2)');
30
+ console.log('@nac3/runtime CLI 2.3.0-alpha.2 (Native Agent Contract v2.3)');
31
31
  }
32
32
 
33
33
  if (!cmd || cmd === '--help' || cmd === '-h') { showHelp(); process.exit(0); }