@nac3/runtime 2.8.0 → 2.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/CHANGELOG.md +198 -0
- package/README.md +10 -0
- package/SPEC.md +45 -4
- package/contract-head.json +4 -4
- package/dist/cli-levels.json +2 -2
- package/dist/cli-lint.mjs +255 -6
- package/dist/cli.js +6 -3
- package/dist/nac-chat-client.browser.js +19 -6
- package/dist/nac-chat-client.cjs +19 -6
- package/dist/nac-chat-client.mjs +19 -6
- package/dist/nac-mcp-interop.browser.js +636 -0
- package/dist/nac-mcp-interop.cjs +641 -0
- package/dist/nac-mcp-interop.d.ts +57 -0
- package/dist/nac-mcp-interop.mjs +641 -0
- package/dist/nac-v2-extensions.d.ts +1 -1
- package/dist/nac.browser.js +304 -69
- package/dist/nac.cjs +304 -69
- package/dist/nac.d.ts +1 -1
- package/dist/nac.mjs +304 -69
- package/package.json +28 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,203 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.9.1 -- 2026-11-28
|
|
4
|
+
|
|
5
|
+
A PATCH release, and every line of it came from an adversarial review
|
|
6
|
+
of the published 2.9.0 run on 2026-11-28. Nine findings, nine fixes,
|
|
7
|
+
no new capability and no change to the contract's vocabulary. Two were
|
|
8
|
+
security defects with a proof-of-concept that ran before the fix was
|
|
9
|
+
written.
|
|
10
|
+
|
|
11
|
+
### The two that were exploitable
|
|
12
|
+
|
|
13
|
+
**`edit_field` executed its own argument (XSS).** The editor built its
|
|
14
|
+
title with `innerHTML` and concatenated the `nac_id` into it, so an id
|
|
15
|
+
carrying markup ran. The pattern is the one the spec asks adopters for
|
|
16
|
+
-- ids built from data, `"row." + title` -- which makes a user-supplied
|
|
17
|
+
title a stored XSS triggered when an agent opens that row's editor.
|
|
18
|
+
Measured in Chromium: `data-nac-id='row.<img src=x onerror=...>'` plus
|
|
19
|
+
`NAC.edit_field(thatId)` set the flag. The title is now written as
|
|
20
|
+
text, the way `toast()` and `confirm_dialog()` already did -- the same
|
|
21
|
+
`<span class="title">`, same styling.
|
|
22
|
+
|
|
23
|
+
**The interop sent the host's bearer wherever the peer pointed.**
|
|
24
|
+
`import_remote_tree(payload, conn)` takes the connection from the HOST
|
|
25
|
+
and the payload from the PEER; the ack subscription was built from
|
|
26
|
+
`payload.ack_endpoint` and carried `conn.bearer` on the query string,
|
|
27
|
+
with no same-origin check. A peer could name its own collector and the
|
|
28
|
+
browser delivered the credential. Now the credential travels only to
|
|
29
|
+
the origin of `conn.endpoint`, or to an endpoint the host names itself
|
|
30
|
+
in the new `conn.ack_endpoint`. A same-origin `ack_endpoint` -- the
|
|
31
|
+
shape every real bridge has -- still works. A cross-origin one is
|
|
32
|
+
refused by name on the handle (`handle.ack_refused`) and announced as
|
|
33
|
+
`nac:interop:ack_refused`, never in silence. The bearer still rides the
|
|
34
|
+
query string, because `EventSource` cannot carry headers: that is why
|
|
35
|
+
pinning the origin is the fix.
|
|
36
|
+
|
|
37
|
+
### SPEC 19.3 now applies to the family, not to eight names
|
|
38
|
+
|
|
39
|
+
19.3 lists eight primitives and then says *"and any other that
|
|
40
|
+
resolves a name by querying the document"*. Measured: 69 of the 151
|
|
41
|
+
exports still died with a raw `ReferenceError: document is not
|
|
42
|
+
defined` in a process with no document -- the same defect D-26 closed
|
|
43
|
+
one layer up. All of them now refuse by name with `no_document`,
|
|
44
|
+
**through the channel each one already used**: a primitive that returns
|
|
45
|
+
a promise rejects, one that returns a value throws. `NAC.documentPrimitives()`
|
|
46
|
+
publishes the declaration so a caller can ask before calling.
|
|
47
|
+
|
|
48
|
+
The worst of the 69 was **`wait_for`**, which scheduled its timeout
|
|
49
|
+
BEFORE touching the document: the error came out of the timer, outside
|
|
50
|
+
every `try/catch` the caller could write, and **killed the Node
|
|
51
|
+
process**. A `.catch()` could not reach it. Guarded at entry now, so
|
|
52
|
+
no timer is ever scheduled.
|
|
53
|
+
|
|
54
|
+
### A `nac_id` is escaped before it reaches a selector
|
|
55
|
+
|
|
56
|
+
Every id the runtime resolves went straight into a quoted attribute
|
|
57
|
+
selector. An id with a double quote closed the string and the browser
|
|
58
|
+
answered with a raw `DOMException` ("is not a valid selector") where
|
|
59
|
+
the contract promises `not_found`; a comma could continue the selector
|
|
60
|
+
LIST and resolve a different element. 59 interpolations now go through
|
|
61
|
+
one escaper, which escapes the only two characters that can break out
|
|
62
|
+
of a CSS string and leaves the dots in every id alone. Not
|
|
63
|
+
`CSS.escape()`: that one escapes for use as an identifier.
|
|
64
|
+
|
|
65
|
+
### Smaller, and each measured
|
|
66
|
+
|
|
67
|
+
* **A colon in a peer's `app_id` made an ambiguous namespace.**
|
|
68
|
+
`remote:<ns>:<peer_id>` splits at the first colon, and the namespace
|
|
69
|
+
defaults to the `app_id` the peer chose: a peer declaring
|
|
70
|
+
`"bank:widget"` routed `remote:bank:widget:pay` to an unrelated peer
|
|
71
|
+
named `bank`. Refused at import now.
|
|
72
|
+
* **An outgoing `postMessage` with no declared `target_origin` went
|
|
73
|
+
to `'*'`.** It now goes to the origin of the iframe the adopter
|
|
74
|
+
pointed at, read from its `src`, and says so once per message.
|
|
75
|
+
`'*'` survives where it is the only thing that works -- `srcdoc`,
|
|
76
|
+
`about:blank`, no `src` -- and where an adopter declares it.
|
|
77
|
+
* **`nac validate --harness` runs the page inside a Node `vm`**, and a
|
|
78
|
+
`vm` is not a security boundary. The implementation has said so since
|
|
79
|
+
it was written; the CLI help and this package's README now say it
|
|
80
|
+
too, where an adopter reads.
|
|
81
|
+
|
|
82
|
+
### No behaviour of the contract changed
|
|
83
|
+
|
|
84
|
+
No role, event, attribute or manifest field was added, removed or
|
|
85
|
+
renamed. The one API addition is `NAC.documentPrimitives()`, which
|
|
86
|
+
reports a declaration. Everything else is a refusal that used to be a
|
|
87
|
+
crash, or a destination that used to be "anywhere".
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## 2.9.0 -- 2026-11-27
|
|
91
|
+
|
|
92
|
+
A MINOR release, additive, and the one this project found by measuring
|
|
93
|
+
**itself**. Three things: the **document vocabulary** (five roles), a
|
|
94
|
+
static validator that follows a `<script src>` reference, and -- added
|
|
95
|
+
on the same day, by owner decisions D-30 and D-31 -- a **fourth package
|
|
96
|
+
entry** and the first mention of `declareVirtual` in the normative text.
|
|
97
|
+
|
|
98
|
+
### A fourth entry: `@nac3/runtime/mcp-interop` (D-31)
|
|
99
|
+
|
|
100
|
+
Cross-app navigation ships. `js/nac-mcp-interop.js` had been in `main`
|
|
101
|
+
with a header that said *"v2.3 PREVIEW. Lives in branch
|
|
102
|
+
feat/nac-interop-mcp"*, while the build emitted three bundles -- so
|
|
103
|
+
`npm install @nac3/runtime` brought none of it, and the tree insinuated
|
|
104
|
+
a capability that no door delivered (`PND-137`).
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
import '@nac3/runtime'; // first: the runtime
|
|
108
|
+
import '@nac3/runtime/mcp-interop'; // then: this
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
It adds four members to `window.NAC` -- `export_tree`,
|
|
112
|
+
`import_remote_tree`, `list_remote_apps`, `disconnect_remote` -- and
|
|
113
|
+
teaches the ordinary primitives the `remote:<namespace>:<peer_id>` id
|
|
114
|
+
form, so a second application becomes addressable **by name** from the
|
|
115
|
+
first. Its specification is `docs/NAC_INTEROP_MCP.md`.
|
|
116
|
+
|
|
117
|
+
It is **optional**: nothing in `SPEC.md` requires it and no conformance
|
|
118
|
+
level mentions it. Publishing it surfaced two real defects, both
|
|
119
|
+
measured before they were written:
|
|
120
|
+
|
|
121
|
+
* the file ended in `})(window);` -- the only one of the four published
|
|
122
|
+
sources that demanded a browser global, so the ESM and CJS bundles
|
|
123
|
+
could not have been loaded outside one. It now carries the same
|
|
124
|
+
`typeof window !== 'undefined'` guard its three siblings carry.
|
|
125
|
+
* the three functions that report through DOM events died with
|
|
126
|
+
`ReferenceError` in a process with no document. They now refuse by
|
|
127
|
+
name with `no_document`, which is the rule **D-26** wrote for the
|
|
128
|
+
core primitives in 2.8.0. `list_remote_apps()` reads state only and
|
|
129
|
+
works anywhere.
|
|
130
|
+
|
|
131
|
+
### `declareVirtual` is named in 15.12.1 for the first time (D-30)
|
|
132
|
+
|
|
133
|
+
A behaviour clarification, not a code change. Section 15.12.1 (2.7.0)
|
|
134
|
+
sent virtualised collections to the extension contract of section 15,
|
|
135
|
+
and `NAC.declareVirtual(spec)` -- in the extensions module since 2.0 --
|
|
136
|
+
answers the same surface through the DOM door, returning `null` for
|
|
137
|
+
BOTH failures where rule 3 of that section requires two distinct codes.
|
|
138
|
+
The owner blessed the 15.12.1 door: a virtualised collection enters
|
|
139
|
+
through the extension contract, and `declareVirtual` is **the path that
|
|
140
|
+
came before it and keeps working**. It is neither removed nor deprecated
|
|
141
|
+
into a warning (promise 7 of section 12), and the text now says what it
|
|
142
|
+
cannot do, so the choice between the two stops looking like taste.
|
|
143
|
+
|
|
144
|
+
### The five roles, and why the measurement was in the tens of thousands
|
|
145
|
+
|
|
146
|
+
The 2.8.0 vocabulary closed the gap between what the normative text
|
|
147
|
+
declared and what this tree USED -- in manifests and in scripts. It did
|
|
148
|
+
not close the one in the **markup the site serves**. Measured with the
|
|
149
|
+
published validator over the whole tree on 2026-11-27:
|
|
150
|
+
|
|
151
|
+
| What | Before | After |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| Roles section 1 declares | 65 | **70** |
|
|
154
|
+
| Roles with no completion event (6.4) | 41 | **46** |
|
|
155
|
+
| Elements on served pages carrying an undeclared role | **45 677** | 0 |
|
|
156
|
+
| Pages affected | 526 | 0 |
|
|
157
|
+
| Registries the role gate confronts | 7 | **9** |
|
|
158
|
+
|
|
159
|
+
Those 45 677 elements were not hand-written markup: a single producer
|
|
160
|
+
emits them -- the generator that renders this specification as a NAC3
|
|
161
|
+
page. So the document that declares the vocabulary was being served
|
|
162
|
+
marked up in words it did not declare, 354 times per page, and the only
|
|
163
|
+
thing that could see it was the published validator at severity `warn`,
|
|
164
|
+
which nobody was running over the whole tree.
|
|
165
|
+
|
|
166
|
+
The five are `heading`, `list-item`, `code`, `code-inline` and `note`
|
|
167
|
+
(SPEC.md 1.2, **Document**). All read-only; all in the no-completion-event
|
|
168
|
+
list of 6.4, never in the click family map -- putting a read-only role in
|
|
169
|
+
that map would make `click()` promise a completion nobody emits.
|
|
170
|
+
`list` and `paragraph` were already declared, so `list-item` and `heading`
|
|
171
|
+
being absent was half a family, which is why the count was what it was.
|
|
172
|
+
|
|
173
|
+
Two new registries in `check-role-registries.mjs`: the **markup the site
|
|
174
|
+
serves** (the one nothing was reading) and the **prose list of 6.4** (a
|
|
175
|
+
hand-written count nobody compared with the runtime).
|
|
176
|
+
|
|
177
|
+
### The lint follows a reference
|
|
178
|
+
|
|
179
|
+
Until this release a `NAC.register_role()` call living in the file a page
|
|
180
|
+
names with `<script src>` was invisible to the static lint: it reads one
|
|
181
|
+
file at a time and did not follow the reference. An adopter who puts the
|
|
182
|
+
plugin in its own file -- the normal thing to do -- had no lock in either
|
|
183
|
+
direction: a real asymmetry went unreported, and a legitimate
|
|
184
|
+
`nac3.roles.json` was reported as `role_registration_orphan` because the
|
|
185
|
+
only call using it was in a file nobody read.
|
|
186
|
+
|
|
187
|
+
The lint now reads a reference that is **relative**, resolves **inside**
|
|
188
|
+
the linted root and **exists**. A remote URL, a root-absolute path (whose
|
|
189
|
+
meaning depends on a mount the lint does not know) and a path that climbs
|
|
190
|
+
out of the root are still not read -- and when not reading one could
|
|
191
|
+
change the verdict on a page, the lint now SAYS so (new `script_not_read`,
|
|
192
|
+
severity `warn`) instead of going quiet. The finding is attributed to the
|
|
193
|
+
file that contains the call and names the page that loads it.
|
|
194
|
+
|
|
195
|
+
### Compatibility
|
|
196
|
+
|
|
197
|
+
Additive throughout. No canonical role changed meaning, no published event
|
|
198
|
+
was renamed, no spelling that worked stopped working, and a manifest
|
|
199
|
+
written against 2.6.0 registers and runs unmodified.
|
|
200
|
+
|
|
3
201
|
## 2.8.0 -- 2026-11-25
|
|
4
202
|
|
|
5
203
|
A MINOR release, and the largest addition of surface the protocol has
|
package/README.md
CHANGED
|
@@ -131,6 +131,15 @@ asks the runtime the same questions the browser mode asks -- with the
|
|
|
131
131
|
same observer and the same decider table, so the two modes cannot form
|
|
132
132
|
two opinions about what the contract says.
|
|
133
133
|
|
|
134
|
+
> **Only point `--harness` at HTML you trust.** The sandbox is a Node
|
|
135
|
+
> `vm` context with no network, no filesystem and no storage beyond a
|
|
136
|
+
> stub, which is a long way from nothing -- but a `vm` is not a
|
|
137
|
+
> security boundary, and a script that reaches a constructor can leave
|
|
138
|
+
> it. Running this mode over a page you did not write is running that
|
|
139
|
+
> page's code. The plain directory mode (`validate <dir>` with no
|
|
140
|
+
> flag) never executes anything and is the one to use on markup from
|
|
141
|
+
> elsewhere.
|
|
142
|
+
|
|
134
143
|
Of the eleven requirements of SPEC.md section 8 it **decides five** and
|
|
135
144
|
**declares the other six**, each with the reason it cannot:
|
|
136
145
|
|
|
@@ -179,6 +188,7 @@ the four requirements of level 1 are about what the page DOES.
|
|
|
179
188
|
import NAC from '@nac3/runtime';
|
|
180
189
|
import '@nac3/runtime/extensions'; // v2.0 brownfield primitives
|
|
181
190
|
import '@nac3/runtime/chat-client'; // reference voice + chat client
|
|
191
|
+
import '@nac3/runtime/mcp-interop'; // optional: drive a SECOND app by name
|
|
182
192
|
```
|
|
183
193
|
|
|
184
194
|
## Status
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NAC3 -- Native Agent Contract
|
|
2
2
|
|
|
3
|
-
**Version:** 2.
|
|
3
|
+
**Version:** 2.9.1 (stable -- the v2.5 surface, the v2.6 plugin extension hooks (discovery, self-description, emitter-listen), the v2.7 authenticity surface (HMAC-verified manifests, dispatch provenance, the probing validator, the surface doors of 15.12, the headless profile), the v2.8 vocabulary (45 surface roles, 7 declared aliases, the complete event table of 6.4, and `register_role`) and the v2.9 document vocabulary: the five roles this project's own generated pages had been painting since before the vocabulary existed)
|
|
4
4
|
**Status:** Stable release. The npm dist-tag `latest` points here; section 9.1 states what that guarantees and what a prerelease does not. This document states its version in exactly one place, the line above. The shipped RFCs and their Layer 2 + Layer 3 evidence are listed in `README.md` and `runtime/CHANGELOG.md`.
|
|
5
5
|
**License:** Apache-2.0
|
|
6
6
|
**Editor:** Yujin (yujin.app)
|
|
@@ -240,6 +240,32 @@ verb, and one is the door section 15.12 decided on.
|
|
|
240
240
|
| `paragraph` | A prose block addressable for reading. Declared for the same reason as `value`: under section 19 reading is a capability, not a side effect of having a screen. | `<p data-nac-role="paragraph">` |
|
|
241
241
|
| `canvas` | A host whose interior is **not in the DOM**. A role is not enough to operate it: its interior is reached through the plugin extension contract of section 15, which is the door section 15.12 assigned to this surface. Declaring `canvas` without that contract would promise what cannot be delivered. | `<div data-nac-role="canvas">` |
|
|
242
242
|
|
|
243
|
+
**Document (v2.9).** The group that measuring this project's own site
|
|
244
|
+
put in the table. The generator that renders this specification as a
|
|
245
|
+
NAC3 page paints these five on every page it emits -- 45 677 elements
|
|
246
|
+
across 526 pages, measured on 2026-11-27 with the published validator
|
|
247
|
+
-- and until v2.9 the vocabulary did not have them, so the document
|
|
248
|
+
that declares the vocabulary was served marked up in words it did not
|
|
249
|
+
declare. They are **additive** and read-only: section 12 promise 3
|
|
250
|
+
holds, and none of them has a completion event (section 6.4).
|
|
251
|
+
|
|
252
|
+
They are declared rather than un-painted because document structure is
|
|
253
|
+
a capability, not decoration. Under section 19 reading is not a side
|
|
254
|
+
effect of having a screen: an agent with no screen navigates prose by
|
|
255
|
+
heading, and `code` is the difference between text that may be
|
|
256
|
+
summarised and text that must be reproduced. `list` and `paragraph`
|
|
257
|
+
were already declared, so `list-item` and `heading` being absent was
|
|
258
|
+
half a family -- which is why the measurement came back in the tens of
|
|
259
|
+
thousands rather than in dozens.
|
|
260
|
+
|
|
261
|
+
| Role | Meaning | Example |
|
|
262
|
+
|------|---------|---------|
|
|
263
|
+
| `heading` | A section title. Its depth travels in `data-nac-level`, so the headings of a document are an outline an agent can walk without parsing prose. | `<h2 data-nac-role="heading" data-nac-level="2">` |
|
|
264
|
+
| `list-item` | One entry of a `list`. Declared because the host was already declared and its entries are what an agent addresses. | `<li data-nac-role="list-item">` |
|
|
265
|
+
| `code` | A block of code, or of any text that must be read **verbatim**. Read-only. The distinction from `paragraph` is normative for a reader: a paraphrase of a code block is wrong. | `<pre data-nac-role="code">` |
|
|
266
|
+
| `code-inline` | The same promise inside a line of prose. Declared separately from `code` because collapsing whitespace is correct for one and wrong for the other. | `<code data-nac-role="code-inline">` |
|
|
267
|
+
| `note` | An aside: a remark that belongs to the page but not to its main flow. Read-only. | `<blockquote data-nac-role="note">` |
|
|
268
|
+
|
|
243
269
|
### 1.3 Unknown roles
|
|
244
270
|
|
|
245
271
|
Roles outside this list are reserved for future use. A NAC-strict
|
|
@@ -1389,7 +1415,7 @@ The `tab` row above gained its failure event in v2.8:
|
|
|
1389
1415
|
not in this table, so `NAC.click()` on a tab whose activation was
|
|
1390
1416
|
refused waited out its full timeout instead of rejecting at once.
|
|
1391
1417
|
|
|
1392
|
-
**The forty-
|
|
1418
|
+
**The forty-six roles with no completion event of their own.** They are
|
|
1393
1419
|
listed because the absence is part of the contract, not an
|
|
1394
1420
|
oversight: `plugin`, `section`, `region`, `navigation`,
|
|
1395
1421
|
`data-table`, `confirm-dialog`, `draggable`, `drop-target`, `map`,
|
|
@@ -1398,8 +1424,8 @@ oversight: `plugin`, `section`, `region`, `navigation`,
|
|
|
1398
1424
|
`toast-region`, `feedback`, `modal`, `drawer`, `bottom-sheet`, `tablist`,
|
|
1399
1425
|
`tabpanel`, `stepper`, `accordion-section`, `breadcrumb`,
|
|
1400
1426
|
`pagination-control`, `avatar`, `presence-indicator`, `skeleton`,
|
|
1401
|
-
`empty-state`, `list`, `row`, `menu`, `label`, `value`, `paragraph
|
|
1402
|
-
and `
|
|
1427
|
+
`empty-state`, `list`, `row`, `menu`, `label`, `value`, `paragraph`,
|
|
1428
|
+
`canvas`, `heading`, `list-item`, `code`, `code-inline` and `note`.
|
|
1403
1429
|
|
|
1404
1430
|
Four of those are structural hosts, two are driven by
|
|
1405
1431
|
`NAC.drag_drop()` rather than by a click, and the rest are
|
|
@@ -2897,6 +2923,21 @@ by querying the document. The rules:
|
|
|
2897
2923
|
unmounted behaves as (2) and (3) say: the name stays valid, the
|
|
2898
2924
|
node does not, and the answer says which of the two happened.
|
|
2899
2925
|
|
|
2926
|
+
**`declareVirtual` is the path that came before this door, and it keeps
|
|
2927
|
+
working.** `NAC.declareVirtual(spec)` has been in the extensions module
|
|
2928
|
+
since 2.0 -- a slug pattern with `{i}`, a count and a resolver -- and it
|
|
2929
|
+
answers this same surface through the DOM door. It resolves a row in one
|
|
2930
|
+
call and returns `null` for BOTH failures: the pattern that matched
|
|
2931
|
+
nothing, and the index outside the collection. That is one code for two
|
|
2932
|
+
answers, which is what rule 3 forbids. The owner blessed THIS door (D-30,
|
|
2933
|
+
2026-11-27): a virtualised collection enters through the extension
|
|
2934
|
+
contract of section 15, and that is what a new adopter writes.
|
|
2935
|
+
`declareVirtual` is neither removed nor deprecated into a warning --
|
|
2936
|
+
promise 7 of section 12 means code written against it in 2.0 keeps
|
|
2937
|
+
running unchanged -- but it does not satisfy rule 3, so an agent driving
|
|
2938
|
+
a collection through it can only retry blindly. The two are not
|
|
2939
|
+
equivalent, and which one a tree uses is not a matter of taste.
|
|
2940
|
+
|
|
2900
2941
|
Reference plugin and receipt: `demos/v27-virtual-grid/`, 10,000 rows
|
|
2901
2942
|
over a hand-written virtualiser, driven by
|
|
2902
2943
|
`scripts/run-demo-v27-virtual-grid.mjs`.
|
package/contract-head.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"api_schema": 1,
|
|
3
|
-
"chain_head": "sha384-
|
|
4
|
-
"entry_count":
|
|
3
|
+
"chain_head": "sha384-P3/WbjZLa15msTk9IR2RExuDrf4pZOhSWLx7SwdHyhZDcxmUerjgNn4iWtLHQfIU",
|
|
4
|
+
"entry_count": 10,
|
|
5
5
|
"generated_by": "scripts/build-contract-api.mjs",
|
|
6
6
|
"note": "The third of three independent witnesses of the contract chain head (audit N-24). This copy is immutable once published: npm does not allow a version to be republished, so a host that rewrites the chain cannot reach back and change it. If this head disagrees with the one the host serves for this version, do not trust the host. Present from 2.5.0 onward; earlier releases were published before this API existed.",
|
|
7
7
|
"protocol": "NAC3",
|
|
8
|
-
"published_at": "2026-11-
|
|
9
|
-
"runtime_version": "2.
|
|
8
|
+
"published_at": "2026-11-28",
|
|
9
|
+
"runtime_version": "2.9.1",
|
|
10
10
|
"surface": "contract-head-witness",
|
|
11
11
|
"witnesses": {
|
|
12
12
|
"host": "api/index.json served by the web host (chain_head)",
|
package/dist/cli-levels.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generated_by": "runtime/build.mjs from SPEC.md section 8 via scripts/spec-levels.mjs",
|
|
3
3
|
"note": "Build input for the CLI validator. The published, signed copy of the same facts is api/v/<version>/levels.json.",
|
|
4
|
-
"version": "2.
|
|
5
|
-
"spec_version": "2.
|
|
4
|
+
"version": "2.9.1",
|
|
5
|
+
"spec_version": "2.9",
|
|
6
6
|
"locales_required": [
|
|
7
7
|
"es",
|
|
8
8
|
"en",
|
package/dist/cli-lint.mjs
CHANGED
|
@@ -45,7 +45,7 @@ import path from 'node:path';
|
|
|
45
45
|
// hand-typed set of 18 of the 20, missing draggable and drop-target,
|
|
46
46
|
// so the lint reported manifest_role_unknown on pages that follow the
|
|
47
47
|
// specification exactly. Never type this list again.
|
|
48
|
-
const CANONICAL_ROLES = new Set(["plugin","section","region","action","field","option","tab","breadcrumb-item","accordion-toggle","step","pagination-item","confirm-button","sort-control","filter-control","data-table","navigation","confirm-dialog","draggable","drop-target","button","map","map-layer","map-marker","chart","chart-series","chart-point","calendar","calendar-event","tree","tree-node","tree-children","timeline","timeline-item","carousel","carousel-slide","status","log","toast","toast-region","banner","feedback","modal","drawer","bottom-sheet","combobox","listbox","slider","richtext","tablist","tabpanel","stepper","accordion-section","breadcrumb","pagination-control","avatar","presence-indicator","skeleton","empty-state","list","row","menu","label","value","paragraph","canvas"]);
|
|
48
|
+
const CANONICAL_ROLES = new Set(["plugin","section","region","action","field","option","tab","breadcrumb-item","accordion-toggle","step","pagination-item","confirm-button","sort-control","filter-control","data-table","navigation","confirm-dialog","draggable","drop-target","button","map","map-layer","map-marker","chart","chart-series","chart-point","calendar","calendar-event","tree","tree-node","tree-children","timeline","timeline-item","carousel","carousel-slide","status","log","toast","toast-region","banner","feedback","modal","drawer","bottom-sheet","combobox","listbox","slider","richtext","tablist","tabpanel","stepper","accordion-section","breadcrumb","pagination-control","avatar","presence-indicator","skeleton","empty-state","list","row","menu","label","value","paragraph","canvas","heading","list-item","code","code-inline","note"]);
|
|
49
49
|
|
|
50
50
|
// The declared aliases of SPEC.md section 1.5 (v2.8), DERIVED from
|
|
51
51
|
// that section by the same module. Seven spellings this tree had
|
|
@@ -340,6 +340,168 @@ function elementsOf(block) {
|
|
|
340
340
|
return out;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
/* THE JAVASCRIPT A FILE ACTUALLY RUNS (PND-145, measured 2026-11-27
|
|
344
|
+
while writing the demo card of SPEC 1.4).
|
|
345
|
+
|
|
346
|
+
THE DEFECT. Rule 5b read the file as BYTES: any occurrence of
|
|
347
|
+
register_role('name') counted as a call. So a page that DOCUMENTS
|
|
348
|
+
the mechanism with a literal example -- inside a <code>, which is
|
|
349
|
+
the only honest way to document it -- was reported as calling a
|
|
350
|
+
role it never declares, at severity `error`, which stops a
|
|
351
|
+
pipeline. Measured: demos/index.html, the demos showcase, which has
|
|
352
|
+
no scripts at all. The page was penalised for teaching the feature.
|
|
353
|
+
And it is not a corner: the landing, the manual, the generated
|
|
354
|
+
pages of the normative text and any adopter's own documentation all
|
|
355
|
+
want to quote that line.
|
|
356
|
+
|
|
357
|
+
WHAT COUNTS NOW. For markup, only the bodies of its inline
|
|
358
|
+
<script> elements -- which is what "this file calls" means, and it
|
|
359
|
+
makes prose, <code>, <pre> and HTML comments drop out for free
|
|
360
|
+
rather than by a list of tags to skip. For a file that IS
|
|
361
|
+
JavaScript (.jsx and .tsx by default; .js or .mjs when the adopter
|
|
362
|
+
adds them with --ext) the whole content, minus comments, because a
|
|
363
|
+
call commented out is not a call either.
|
|
364
|
+
|
|
365
|
+
THE LIMIT THAT WAS CLOSED (PND-153, 2026-11-27). Until today a
|
|
366
|
+
call that lived in a SEPARATE file named by <script src> stayed
|
|
367
|
+
invisible: the lint read one file at a time and did not follow the
|
|
368
|
+
reference. That was measured, written down as a passing assertion
|
|
369
|
+
(case 10d of the suite) rather than believed -- and it mattered,
|
|
370
|
+
because putting a plugin in its own file is the NORMAL thing to do,
|
|
371
|
+
so the adopter who does it had no lock at all, in both directions:
|
|
372
|
+
a real asymmetry went unreported, and a legitimate nac3.roles.json
|
|
373
|
+
was reported as an orphan because the only call that used it was in
|
|
374
|
+
a file nobody read. Rule 5c below follows the reference, under
|
|
375
|
+
three conditions that keep it from becoming "walk every .js in the
|
|
376
|
+
tree" (which this file rejects, with reason, two paragraphs down):
|
|
377
|
+
the reference is RELATIVE, it resolves INSIDE the linted root, and
|
|
378
|
+
the file exists. A remote URL, a root-absolute path (whose meaning
|
|
379
|
+
depends on a mount this lint does not know) and a path that climbs
|
|
380
|
+
out of the root are not read -- and when not reading one could
|
|
381
|
+
change the verdict on a page, the lint SAYS so instead of going
|
|
382
|
+
quiet (code script_not_read).
|
|
383
|
+
|
|
384
|
+
THE LIMIT THAT REMAINS: the scanner that drops comments understands
|
|
385
|
+
strings, template literals and both comment forms, but not a
|
|
386
|
+
regular-expression literal containing //. The whole cost of that
|
|
387
|
+
case is a call on that one line going unseen.
|
|
388
|
+
|
|
389
|
+
A <script> whose type is not JavaScript -- a JSON island, an
|
|
390
|
+
HTML template -- is not executed by the browser, so it is not
|
|
391
|
+
executed here either. */
|
|
392
|
+
const JS_LIKE_EXTENSIONS = [
|
|
393
|
+
'.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx',
|
|
394
|
+
];
|
|
395
|
+
|
|
396
|
+
function stripJsComments(src) {
|
|
397
|
+
let out = '';
|
|
398
|
+
let i = 0;
|
|
399
|
+
const n = src.length;
|
|
400
|
+
while (i < n) {
|
|
401
|
+
const c = src[i];
|
|
402
|
+
const d = src[i + 1];
|
|
403
|
+
if (c === '/' && d === '/') {
|
|
404
|
+
while (i < n && src[i] !== '\n') i++;
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
if (c === '/' && d === '*') {
|
|
408
|
+
i += 2;
|
|
409
|
+
while (i < n && !(src[i] === '*' && src[i + 1] === '/')) {
|
|
410
|
+
if (src[i] === '\n') out += '\n';
|
|
411
|
+
i++;
|
|
412
|
+
}
|
|
413
|
+
i += 2;
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
417
|
+
/* The role name of a real call lives INSIDE a string literal,
|
|
418
|
+
so string contents are kept. Only the quoting is tracked, to
|
|
419
|
+
stop a // or a /* inside a string from being read as the
|
|
420
|
+
start of a comment. */
|
|
421
|
+
const q = c;
|
|
422
|
+
out += c;
|
|
423
|
+
i++;
|
|
424
|
+
while (i < n) {
|
|
425
|
+
if (src[i] === '\\') { out += src.slice(i, i + 2); i += 2; continue; }
|
|
426
|
+
out += src[i];
|
|
427
|
+
if (src[i] === q) { i++; break; }
|
|
428
|
+
i++;
|
|
429
|
+
}
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
out += c;
|
|
433
|
+
i++;
|
|
434
|
+
}
|
|
435
|
+
return out;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const EXECUTABLE_SCRIPT_TYPE = /^(?:text|application)\/(?:java|ecma)script(?:;|$)|^module$/i;
|
|
439
|
+
|
|
440
|
+
/* THE JAVASCRIPT A PAGE LOADS FROM ANOTHER FILE (PND-153).
|
|
441
|
+
|
|
442
|
+
Returns one entry per <script src> of a markup file: either
|
|
443
|
+
{ rel, abs, body } for a reference this lint is allowed to read, or
|
|
444
|
+
{ ref, skipped } with the reason it is not. Nothing is thrown and
|
|
445
|
+
nothing is guessed: a reference that cannot be resolved honestly is
|
|
446
|
+
reported as unread, because the alternative -- reading a file the
|
|
447
|
+
page may not even be loading -- would make every finding about it
|
|
448
|
+
fiction.
|
|
449
|
+
|
|
450
|
+
The three conditions, and why each one:
|
|
451
|
+
RELATIVE a root-absolute src means whatever the deployment
|
|
452
|
+
mounts the tree at (this project serves under
|
|
453
|
+
/nac-spec/, decision D-02); the lint does not know
|
|
454
|
+
the mount of the tree it is given.
|
|
455
|
+
INSIDE a path that climbs out of the linted root is outside
|
|
456
|
+
the subject. Reading it would report findings about
|
|
457
|
+
a file the caller did not ask about.
|
|
458
|
+
EXISTS a src that does not resolve is already rule 6's and
|
|
459
|
+
check-tree-links' business, not this rule's. */
|
|
460
|
+
function referencedScripts(file, content, root) {
|
|
461
|
+
const out = [];
|
|
462
|
+
if (JS_LIKE_EXTENSIONS.indexOf(path.extname(file).toLowerCase()) >= 0) return out;
|
|
463
|
+
for (const m of content.matchAll(/<script\b([^>]*?)\ssrc\s*=\s*["']([^"']*)["']([^>]*)>/gi)) {
|
|
464
|
+
const attrs = (m[1] || '') + ' ' + (m[3] || '');
|
|
465
|
+
const type = (/\btype\s*=\s*["']?([^"'\s>]+)/i.exec(attrs) || [])[1];
|
|
466
|
+
if (type && !EXECUTABLE_SCRIPT_TYPE.test(type.trim())) continue;
|
|
467
|
+
const ref = (m[2] || '').trim();
|
|
468
|
+
if (!ref) continue;
|
|
469
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(ref) || ref.slice(0, 2) === '//') {
|
|
470
|
+
out.push({ ref, skipped: 'it is a remote URL' });
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (ref[0] === '/') {
|
|
474
|
+
out.push({ ref, skipped: 'it is root-absolute, so where it points depends on the mount of the deployment and not on this tree' });
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const clean = ref.split('#')[0].split('?')[0];
|
|
478
|
+
if (!clean) continue;
|
|
479
|
+
const abs = path.resolve(path.dirname(file), clean);
|
|
480
|
+
const rel = path.relative(root, abs);
|
|
481
|
+
if (!rel || rel.slice(0, 2) === '..' || path.isAbsolute(rel)) {
|
|
482
|
+
out.push({ ref, skipped: 'it resolves outside the linted root' });
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
let body;
|
|
486
|
+
try { body = fs.readFileSync(abs, 'utf8'); }
|
|
487
|
+
catch (_) { out.push({ ref, skipped: 'it does not resolve to a readable file in this tree' }); continue; }
|
|
488
|
+
out.push({ ref, abs, rel: rel.split(path.sep).join('/'), body: stripJsComments(body) });
|
|
489
|
+
}
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function executableScript(file, content) {
|
|
494
|
+
const ext = path.extname(file).toLowerCase();
|
|
495
|
+
if (JS_LIKE_EXTENSIONS.indexOf(ext) >= 0) return stripJsComments(content);
|
|
496
|
+
let out = '';
|
|
497
|
+
for (const m of content.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)) {
|
|
498
|
+
const type = (/\btype\s*=\s*["']?([^"'\s>]+)/i.exec(m[1] || '') || [])[1];
|
|
499
|
+
if (type && !EXECUTABLE_SCRIPT_TYPE.test(type.trim())) continue;
|
|
500
|
+
out += stripJsComments(m[2]) + '\n';
|
|
501
|
+
}
|
|
502
|
+
return out;
|
|
503
|
+
}
|
|
504
|
+
|
|
343
505
|
/* The manifest inventory of a tree: every element every NAC.register
|
|
344
506
|
call declares, with the file it came from.
|
|
345
507
|
|
|
@@ -513,11 +675,18 @@ function lintFiles(dir, files, extensions) {
|
|
|
513
675
|
return false;
|
|
514
676
|
}
|
|
515
677
|
|
|
678
|
+
/* PND-153: one finding per (script, role), not one per page that
|
|
679
|
+
loads it. A shared plugin file loaded by nine pages is one
|
|
680
|
+
asymmetry, and reporting it nine times is how a reader stops
|
|
681
|
+
reading. */
|
|
682
|
+
const seenViaSrc = new Set();
|
|
683
|
+
|
|
516
684
|
for (const file of files) {
|
|
517
685
|
let content;
|
|
518
686
|
try { content = fs.readFileSync(file, 'utf8'); }
|
|
519
687
|
catch (_) { continue; }
|
|
520
688
|
const rel = path.relative(dir, file);
|
|
689
|
+
const findingsBefore = findings.length;
|
|
521
690
|
|
|
522
691
|
/* PND-132: the registry that applies to THIS file. */
|
|
523
692
|
const registeredRoles = rolesFor(path.dirname(file));
|
|
@@ -673,16 +842,96 @@ function lintFiles(dir, files, extensions) {
|
|
|
673
842
|
the lint cannot see makes every OTHER finding about that
|
|
674
843
|
element unreliable, while a declaration nobody uses yet is
|
|
675
844
|
merely untidy. */
|
|
676
|
-
for (const m of content
|
|
845
|
+
for (const m of executableScript(file, content)
|
|
846
|
+
.matchAll(/\bregister_role\s*\(\s*['"]([a-z][a-z0-9-]*)['"]/g)) {
|
|
677
847
|
if (!markUsed(path.dirname(file), m[1])) {
|
|
678
848
|
findings.push({
|
|
679
849
|
severity: 'error',
|
|
680
850
|
code: 'role_registration_undeclared',
|
|
681
851
|
file: rel,
|
|
682
|
-
message: 'this file calls NAC.register_role("' + m[1] +
|
|
683
|
-
'beside it -- or in any directory between it and
|
|
684
|
-
'it. A static validator cannot see a role declared
|
|
685
|
-
'finding about an element carrying that role would be
|
|
852
|
+
message: 'the JavaScript this file RUNS calls NAC.register_role("' + m[1] +
|
|
853
|
+
'") and no nac3.roles.json beside it -- or in any directory between it and ' +
|
|
854
|
+
'the linted root -- declares it. A static validator cannot see a role declared ' +
|
|
855
|
+
'in JavaScript, so every finding about an element carrying that role would be ' +
|
|
856
|
+
'unreliable (SPEC.md 1.4). Prose that merely QUOTES the call -- inside a <code>, ' +
|
|
857
|
+
'a <pre> or a comment -- is not a call and is not reported (PND-145).'
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/* Rule 5c: the same asymmetry, when the call lives in the file the
|
|
863
|
+
page LOADS (PND-153). role_registration_undeclared error
|
|
864
|
+
script_not_read warn
|
|
865
|
+
|
|
866
|
+
THE DEFECT THIS CLOSES, measured on this tree: the only call of
|
|
867
|
+
demos/v28-register-role/ that a static reader could reach was
|
|
868
|
+
the inline one, and the plugin file beside it -- line 111,
|
|
869
|
+
register_role('gantt-bar') -- was never read. The receipt of
|
|
870
|
+
that demo did not depend on it only because the page declares
|
|
871
|
+
the role BOTH ways on purpose. An adopter who puts the plugin
|
|
872
|
+
in its own file, which is the normal thing to do, had no lock.
|
|
873
|
+
|
|
874
|
+
THE ATTRIBUTION, and it is a choice: the finding names the file
|
|
875
|
+
that CONTAINS the call, and the message names the page that
|
|
876
|
+
loads it. The call is the defect's location; the page is how
|
|
877
|
+
anyone finds it.
|
|
878
|
+
|
|
879
|
+
The registry chain is tried from the SCRIPT's directory first
|
|
880
|
+
and then from the PAGE's, because SPEC 1.4 puts the declaration
|
|
881
|
+
beside the markup and a shared plugin can sit in a directory of
|
|
882
|
+
its own. Only a role neither chain declares is reported. */
|
|
883
|
+
const loaded = referencedScripts(file, content, dir);
|
|
884
|
+
for (const s of loaded) {
|
|
885
|
+
if (!s.body) continue;
|
|
886
|
+
for (const m of s.body
|
|
887
|
+
.matchAll(/\bregister_role\s*\(\s*['"]([a-z][a-z0-9-]*)['"]/g)) {
|
|
888
|
+
const role = m[1];
|
|
889
|
+
const declared = markUsed(path.dirname(s.abs), role) || markUsed(path.dirname(file), role);
|
|
890
|
+
if (declared) continue;
|
|
891
|
+
const key = s.rel + '\u0000' + role;
|
|
892
|
+
if (seenViaSrc.has(key)) continue;
|
|
893
|
+
seenViaSrc.add(key);
|
|
894
|
+
findings.push({
|
|
895
|
+
severity: 'error',
|
|
896
|
+
code: 'role_registration_undeclared',
|
|
897
|
+
file: s.rel,
|
|
898
|
+
message: 'this file calls NAC.register_role("' + role + '") and is loaded by ' + rel +
|
|
899
|
+
' through <script src="' + s.ref + '">, and no nac3.roles.json beside either of ' +
|
|
900
|
+
'them -- or in any directory between them and the linted root -- declares it. A ' +
|
|
901
|
+
'static validator cannot see a role declared in JavaScript, so every finding ' +
|
|
902
|
+
'about an element carrying that role would be unreliable (SPEC.md 1.4).'
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/* PND-153, the other half of following a reference: SAYING when it
|
|
908
|
+
did not follow one. A page can load its vocabulary from a remote
|
|
909
|
+
URL, from a root-absolute path or from outside the linted root,
|
|
910
|
+
and this lint reads none of those -- so a role declared there is
|
|
911
|
+
invisible and rule 5 would report it as unknown.
|
|
912
|
+
|
|
913
|
+
Emitted ONLY when the page actually has an unknown-role finding,
|
|
914
|
+
which is the only case where not having read the file changes
|
|
915
|
+
the verdict. Unconditionally it would fire on the 526 generated
|
|
916
|
+
pages of this project alone, every one of them loading the
|
|
917
|
+
runtime by root-absolute path, and a warning that fires 526
|
|
918
|
+
times where it changes nothing is how a reader learns to ignore
|
|
919
|
+
the output. */
|
|
920
|
+
const unread = loaded.filter((x) => x.skipped);
|
|
921
|
+
if (unread.length) {
|
|
922
|
+
const unknownHere = findings.slice(findingsBefore)
|
|
923
|
+
.some((f) => f.code === 'dom_role_unknown' || f.code === 'manifest_role_unknown');
|
|
924
|
+
if (unknownHere) {
|
|
925
|
+
findings.push({
|
|
926
|
+
severity: 'warn',
|
|
927
|
+
code: 'script_not_read',
|
|
928
|
+
file: rel,
|
|
929
|
+
message: 'this page carries a role the specification does not declare, AND it loads ' +
|
|
930
|
+
unread.length + ' script(s) this validator did not read (' +
|
|
931
|
+
unread.map((x) => x.ref + ': ' + x.skipped).join('; ') + '). If one of them ' +
|
|
932
|
+
'calls NAC.register_role for that role, the finding above is wrong and the ' +
|
|
933
|
+
'fix is a nac3.roles.json beside the markup (SPEC.md 1.4), not a change to ' +
|
|
934
|
+
'the page.'
|
|
686
935
|
});
|
|
687
936
|
}
|
|
688
937
|
}
|