elementary-assertions 1.0.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +353 -0
  2. package/LICENSE +21 -0
  3. package/README.md +211 -0
  4. package/bin/elementary-assertions.js +8 -0
  5. package/docs/DEV_TOOLING.md +98 -0
  6. package/docs/NPM_RELEASE.md +177 -0
  7. package/docs/OPERATIONAL.md +159 -0
  8. package/docs/RELEASE_NOTES_TEMPLATE.md +37 -0
  9. package/docs/REPO_WORKFLOWS.md +48 -0
  10. package/package.json +46 -0
  11. package/src/core/accepted-annotations.js +44 -0
  12. package/src/core/assertions.js +2304 -0
  13. package/src/core/determinism.js +95 -0
  14. package/src/core/diagnostics.js +496 -0
  15. package/src/core/ids.js +9 -0
  16. package/src/core/mention-builder.js +272 -0
  17. package/src/core/mention-evidence.js +52 -0
  18. package/src/core/mention-head-resolution.js +108 -0
  19. package/src/core/mention-materialization.js +31 -0
  20. package/src/core/mentions.js +149 -0
  21. package/src/core/output.js +296 -0
  22. package/src/core/projection.js +192 -0
  23. package/src/core/roles.js +164 -0
  24. package/src/core/strings.js +7 -0
  25. package/src/core/tokens.js +53 -0
  26. package/src/core/upstream.js +31 -0
  27. package/src/index.js +6 -0
  28. package/src/render/index.js +5 -0
  29. package/src/render/layouts/compact.js +10 -0
  30. package/src/render/layouts/meaning.js +7 -0
  31. package/src/render/layouts/readable.js +7 -0
  32. package/src/render/layouts/table.js +7 -0
  33. package/src/render/render.js +931 -0
  34. package/src/run.js +278 -0
  35. package/src/schema/seed.elementary-assertions.schema.json +1751 -0
  36. package/src/tools/cli.js +158 -0
  37. package/src/tools/index.js +6 -0
  38. package/src/tools/io.js +55 -0
  39. package/src/validate/ajv.js +20 -0
  40. package/src/validate/coverage.js +215 -0
  41. package/src/validate/determinism.js +115 -0
  42. package/src/validate/diagnostics-strict.js +392 -0
  43. package/src/validate/errors.js +19 -0
  44. package/src/validate/index.js +20 -0
  45. package/src/validate/integrity.js +41 -0
  46. package/src/validate/invariants.js +157 -0
  47. package/src/validate/references.js +110 -0
  48. package/src/validate/schema.js +50 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,353 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ### Added
6
+ - package-contract lock for MIT licensing and packaged `LICENSE` file.
7
+ - `v1.0.0` metadata-flip release-gate evidence recorded in TODO (tests, pack dry-run, clean-install smoke roots).
8
+
9
+ ### Changed
10
+ - `docs/NPM_RELEASE.md` now defines both pre-`1.0.0` Git-tag installs and `1.0.0+` npmjs publication steps.
11
+ - `TODO.md` now includes Phase 17 (`1.0.0` publication readiness).
12
+ - package metadata moved to `version: 1.0.0` with `"private": false` for npmjs publication readiness.
13
+
14
+ ## v0.1.12 - 2026-02-15
15
+
16
+ ### Added
17
+ - Phase 16 diagnostics and strict-check ergonomics hardening (non-public tooling):
18
+ - `dev:diagnose:wiki-upstream` now includes deterministic upstream wikipedia field examples per path (`example` + `example_source_id`)
19
+ - `dev:diagnose:wiki-upstream` now includes predicate-level wikipedia coverage summary with cause buckets
20
+ - `dev:check` now emits strict failure context grouped by invariant family with minimal reproducer pointer and recommended follow-up command
21
+
22
+ ### Changed
23
+ - `docs/DEV_TOOLING.md`, `README.md`, and `TODO.md` synchronized for Phase 16 completion scope.
24
+
25
+ ### Release Evidence
26
+ - Release commit: `c5f7dddc7d320cfb248e675c07d5eb7fef884234`
27
+ - Tag: `v0.1.12`
28
+ - Smoke roots:
29
+ - `C:\code\elementary-assertions-smoke-test\v0.1.12-pretag-smoke-20260215-170910`
30
+ - `C:\code\elementary-assertions-smoke-test\v0.1.12-posttag-smoke-20260215-170945`
31
+ - Rendered smoke output roots:
32
+ - `C:\code\elementary-assertions-smoke-test\v0.1.12-pretag-smoke-20260215-170910\rendered`
33
+ - `C:\code\elementary-assertions-smoke-test\v0.1.12-posttag-smoke-20260215-170945\rendered`
34
+
35
+ ## v0.1.11 - 2026-02-15
36
+
37
+ ### Added
38
+ - Phase 15 dev diagnostics depth parity hardening (non-public tooling):
39
+ - wiki-upstream diagnostics now emit upstream wiki field-path inventory by object family
40
+ - wiki-upstream diagnostics now emit stratified missing-field samples by role class and mention kind
41
+ - fragment hotspot diagnostics now include segment-level host lens (triage-only) in addition to clause-local lens
42
+ - WTI wiring diagnostics now emit explicit non-probe wiring attribution summaries (endpoint state + per-step requested/observed signal families)
43
+
44
+ ### Changed
45
+ - `docs/DEV_TOOLING.md`, `README.md`, and `TODO.md` were synchronized for Phase 15 completion scope.
46
+
47
+ ### Release Evidence
48
+ - Release commit: `768e49edee6b09255a395a86a045041b55c5baed`
49
+ - Tag: `v0.1.11`
50
+ - Smoke roots:
51
+ - `C:\code\elementary-assertions-smoke-test\v0.1.11-pretag-smoke-20260215-164624`
52
+ - `C:\code\elementary-assertions-smoke-test\v0.1.11-posttag-smoke-20260215-164701`
53
+ - Rendered smoke output roots:
54
+ - `C:\code\elementary-assertions-smoke-test\v0.1.11-pretag-smoke-20260215-164624\rendered`
55
+ - `C:\code\elementary-assertions-smoke-test\v0.1.11-posttag-smoke-20260215-164701\rendered`
56
+
57
+ ## v0.1.10 - 2026-02-15
58
+
59
+ ### Added
60
+ - Phase 14 strict validation hardening for `coverage.unresolved[*]`:
61
+ - mention reference existence checks (`mention_ids[*]`)
62
+ - unresolved segment consistency checks for mention and evidence token references
63
+ - evidence token reference existence checks
64
+ - Seed-scoped developer tooling ergonomics across `dev:*` scripts:
65
+ - `--seed <name>`
66
+ - `--artifacts-root <path>`
67
+ - Coverage-audit diagnostics now include per-mention triage rows (`per_mention`) with unresolved context and host candidates.
68
+ - Wiki-upstream diagnostics now support optional upstream correlation mode via `--upstream <path>`.
69
+ - WTI wiring diagnostics now support optional runtime probe mode (`--runtime-probe`) with explicit endpoint checks.
70
+
71
+ ### Changed
72
+ - `npm run dev:reports` now forwards supported seed/artifacts options to all underlying report/diagnostics scripts.
73
+ - README/DEV tooling docs/TODO were synchronized for Phase 14 completion scope.
74
+ - SaaS table markdown golden reference was normalized to current renderer output for smoke parity.
75
+
76
+ ### Release Evidence
77
+ - Release commit: `5b56a28b9c2c35e703a1c75666bb1d58b336c6ac`
78
+ - Tag: `v0.1.10`
79
+ - CI run: `22038001076` (success)
80
+ - Smoke roots:
81
+ - `C:\code\elementary-assertions-smoke-test\v0.1.10-pretag-smoke-20260215-161258`
82
+ - `C:\code\elementary-assertions-smoke-test\v0.1.10-posttag-smoke-20260215-161350`
83
+ - Rendered smoke output roots:
84
+ - `C:\code\elementary-assertions-smoke-test\v0.1.10-pretag-smoke-20260215-161258\rendered`
85
+ - `C:\code\elementary-assertions-smoke-test\v0.1.10-posttag-smoke-20260215-161350\rendered`
86
+
87
+ ## v0.1.9 - 2026-02-15
88
+
89
+ ### Added
90
+ - Strict/dev deep integrity checks for `coverage.unresolved[*]`:
91
+ - sorted + unique `mention_ids`
92
+ - sorted `evidence.token_ids`
93
+ - sorted + type-checked `evidence.upstream_relation_ids`
94
+ - New dev-only diagnostics tooling:
95
+ - `npm run dev:diagnose:wiki-upstream`
96
+ - `npm run dev:diagnose:wti-wiring`
97
+ - `npm run dev:diagnose:coverage-audit`
98
+ - Aggregated non-public diagnostics/report command:
99
+ - `npm run dev:reports`
100
+
101
+ ### Changed
102
+ - Strict/dev diagnostics list determinism was expanded for `diagnostics.suppressed_assertions` ordering/duplicate-id checks.
103
+ - `docs/DEV_TOOLING.md` and `TODO.md` were updated to reflect completed Phase 13 hardening.
104
+
105
+ ## v0.1.8 - 2026-02-15
106
+
107
+ ### Changed
108
+ - Upstream dependency freeze is now pinned to exact `linguistic-enricher@1.1.35`.
109
+ - SaaS golden result-reference baseline was refreshed to capture the upstream acceptance fix for `s1` (`centered` now carries `location=Organization`).
110
+ - Scoped SaaS regression fixtures/tests were updated to lock the new accepted-dependency behavior (`centered -> Organization` as `location`).
111
+
112
+ ## v0.1.7 - 2026-02-14
113
+
114
+ ### Added
115
+ - Full AJV-backed schema contract enforcement in runtime validation.
116
+ - Cross-field integrity invariants:
117
+ - segment/token/mention alignment checks
118
+ - predicate head consistency checks
119
+ - assertion segment-consistency checks
120
+ - Strict diagnostics integrity mode (`validateElementaryAssertions(doc, { strict: true })`).
121
+ - Dedicated strict checker workflow:
122
+ - `npm run dev:check`
123
+ - strict validation over a single input (`--in`) or all golden artifacts.
124
+ - File-origin provenance fidelity for CLI file inputs:
125
+ - `--in` and `--relations` now persist file-origin metadata in `sources.inputs[]`.
126
+ - Renderer contract lock expansion:
127
+ - added parity locks for `md/meaning`.
128
+
129
+ ### Changed
130
+ - `README.md` and `docs/OPERATIONAL.md` now explicitly document:
131
+ - runtime vs strict/dev validation scope
132
+ - provenance levels (`in_memory` vs `file`)
133
+ - contract-locked renderer combinations (`txt/compact`, `md/table`, `md/meaning`).
134
+
135
+ ### Release Evidence
136
+ - Release commit: `554fe1df2f4fb9381bb2b125df1f64a6bf322b2d`
137
+ - Tag: `v0.1.7`
138
+ - CI run: `22025229028` (success)
139
+ - Smoke roots:
140
+ - `C:\code\elementary-assertions-smoke-test\v0.1.7-pretag-smoke-20260214-232200`
141
+ - `C:\code\elementary-assertions-smoke-test\v0.1.7-posttag-smoke-20260214-232230`
142
+ - Rendered smoke output roots:
143
+ - `C:\code\elementary-assertions-smoke-test\v0.1.7-pretag-smoke-20260214-232200\rendered`
144
+ - `C:\code\elementary-assertions-smoke-test\v0.1.7-posttag-smoke-20260214-232230\rendered`
145
+
146
+ ## v0.1.6 - 2026-02-14
147
+
148
+ ### Added
149
+ - Stable validation diagnostics contract:
150
+ - validator failures now throw `ValidationError` with deterministic `err.code`
151
+ - coded failures are wired across schema + integrity validation paths
152
+ - Expanded validation error-code contract tests:
153
+ - `test/unit/validate-errors.contract.test.js`
154
+ - coverage and determinism error-code assertions
155
+ - unknown token/mention refs, invalid head token, unresolved coverage, and suppressed target reference assertions
156
+ - Docs consistency enforcement expanded:
157
+ - explicit release commit staging command in `docs/NPM_RELEASE.md`
158
+ - README includes `docs/DEV_TOOLING.md` in documentation links
159
+ - README documents `ValidationError` stable `code` semantics
160
+ - Golden-reference contract coverage expanded with YAML-parsed structural checks:
161
+ - role arrays always present (`arguments`, `modifiers`, `operators`)
162
+ - legacy `assertions[*].slots` absence
163
+ - required coverage arrays
164
+
165
+ ### Changed
166
+ - `docs/OPERATIONAL.md` now documents the validation error contract:
167
+ - `ValidationError` usage
168
+ - stable `ValidationError.code` semantics for consumer branching
169
+
170
+ ### Release Evidence
171
+ - Release commit: `087e5b8f86b9d897da61d7b8107140a55baaf26b`
172
+ - Tag: `v0.1.6`
173
+ - CI run: `22024520208` (success)
174
+ - Smoke roots:
175
+ - `C:\code\elementary-assertions-smoke-test\v0.1.6-pretag-smoke-20260214-222607`
176
+ - `C:\code\elementary-assertions-smoke-test\v0.1.6-posttag-smoke-20260214-222642`
177
+ - Rendered smoke output roots:
178
+ - `C:\code\elementary-assertions-smoke-test\v0.1.6-pretag-smoke-20260214-222607\rendered`
179
+ - `C:\code\elementary-assertions-smoke-test\v0.1.6-posttag-smoke-20260214-222642\rendered`
180
+
181
+ ## v0.1.5 - 2026-02-14
182
+
183
+ ### Added
184
+ - `run --relations` parser edge-case tests:
185
+ - JSON input file accepted
186
+ - non-object parsed input rejected with explicit validation error
187
+
188
+ ### Changed
189
+ - `v0.1.4` release evidence now includes CI run `22020914080` (success) in docs.
190
+ - Release guide now documents local tarball cleanup after `npm pack`.
191
+
192
+ ### Release Evidence
193
+ - Release commit: `a6698b31cadc1d9dbb9e5f4e1bb51df73a84edf9`
194
+ - Tag: `v0.1.5`
195
+ - CI run: `22024304301` (success)
196
+ - Smoke roots:
197
+ - `C:\code\elementary-assertions-smoke-test\v0.1.5-pretag-smoke-20260214-220932`
198
+ - `C:\code\elementary-assertions-smoke-test\v0.1.5-posttag-smoke-20260214-221001`
199
+ - Rendered smoke output roots:
200
+ - `C:\code\elementary-assertions-smoke-test\v0.1.5-pretag-smoke-20260214-220932\rendered`
201
+ - `C:\code\elementary-assertions-smoke-test\v0.1.5-posttag-smoke-20260214-221001\rendered`
202
+
203
+ ## v0.1.4 - 2026-02-14
204
+
205
+ ### Added
206
+ - Integration coverage for non-public dev report scripts:
207
+ - `test/integration/dev-report-scripts.test.js`
208
+ - validates JSON output shape for:
209
+ - `scripts/dev-report-metrics.js`
210
+ - `scripts/dev-report-fragment-hotspots.js`
211
+ - `scripts/dev-report-maturity.js`
212
+
213
+ ### Changed
214
+ - Validation internals were refactored into focused modules without contract changes:
215
+ - `src/validate/determinism.js`
216
+ - `src/validate/coverage.js`
217
+ - `src/validate/references.js`
218
+ - `src/validate/integrity.js` now orchestrates these modules.
219
+ - CI now executes dev report scripts directly as workflow gates:
220
+ - `npm run dev:report:metrics`
221
+ - `npm run dev:report:hotspots`
222
+ - `npm run dev:report:maturity`
223
+
224
+ ### Release Evidence
225
+ - Release commit: `e116ff6298a6ab139bb5f6b79c109f35f90a20e1`
226
+ - Tag: `v0.1.4`
227
+ - CI run: `22020914080` (success)
228
+ - Smoke roots:
229
+ - `C:\code\elementary-assertions-smoke-test\v0.1.4-pretag-smoke-20260214-175142`
230
+ - `C:\code\elementary-assertions-smoke-test\v0.1.4-posttag-smoke-20260214-175210`
231
+ - Rendered smoke output roots:
232
+ - `C:\code\elementary-assertions-smoke-test\v0.1.4-pretag-smoke-20260214-175142\rendered`
233
+ - `C:\code\elementary-assertions-smoke-test\v0.1.4-posttag-smoke-20260214-175210\rendered`
234
+
235
+ ## v0.1.3 - 2026-02-14
236
+
237
+ ### Added
238
+ - CLI relations replay mode: `run --relations <path>` (routes to `runFromRelations`).
239
+ - Non-public developer report scripts:
240
+ - `npm run dev:report:metrics`
241
+ - `npm run dev:report:hotspots`
242
+ - `npm run dev:report:maturity`
243
+ - Developer tooling scope document: `docs/DEV_TOOLING.md`.
244
+
245
+ ### Changed
246
+ - Validation now enforces deeper deterministic integrity invariants at runtime:
247
+ - duplicate id detection
248
+ - sorted deterministic arrays/evidence checks
249
+ - coverage/unresolved consistency checks
250
+ - `runElementaryAssertions` now requires positive upstream WTI evidence in addition to health-check success.
251
+ - `README.md` and `docs/OPERATIONAL.md` now document:
252
+ - determinism enforcement via validation plus golden/regression tests
253
+ - `--relations` replay path
254
+ - WTI evidence-presence requirement
255
+
256
+ ### Release Evidence
257
+ - Release commit: `d2bb91a16c40b60f1652c1477ec35f5fb736540f`
258
+ - Tag: `v0.1.3`
259
+ - Smoke roots:
260
+ - `C:\code\elementary-assertions-smoke-test\v0.1.3-pretag-smoke-20260214-174438`
261
+ - `C:\code\elementary-assertions-smoke-test\v0.1.3-posttag-smoke-20260214-174516`
262
+ - Rendered smoke output roots:
263
+ - `C:\code\elementary-assertions-smoke-test\v0.1.3-pretag-smoke-20260214-174438\rendered`
264
+ - `C:\code\elementary-assertions-smoke-test\v0.1.3-posttag-smoke-20260214-174516\rendered`
265
+
266
+ ## v0.1.2 - 2026-02-14
267
+
268
+ ### Added
269
+ - Shared release smoke script: `scripts/release-smoke-check.js`.
270
+ - Release notes template: `docs/RELEASE_NOTES_TEMPLATE.md`.
271
+ - Documentation consistency integration test: `test/integration/docs-consistency.test.js`.
272
+
273
+ ### Changed
274
+ - CI smoke step now enforces render generation and txt/md golden parity in addition to API/CLI checks.
275
+ - Release guide (`docs/NPM_RELEASE.md`) now uses the shared smoke script for pre-tag and post-tag verification.
276
+ - README documentation section includes the release notes template link.
277
+
278
+ ### Release Evidence
279
+ - Release commit: `7908ff90c977e0226d9d8b5b6144e4ac648f059f`
280
+ - Tag: `v0.1.2`
281
+ - CI run: `22020450744` (success)
282
+ - Smoke roots:
283
+ - `C:\code\elementary-assertions-smoke-test\v0.1.2-pretag-smoke-20260214-171538`
284
+ - `C:\code\elementary-assertions-smoke-test\v0.1.2-posttag-smoke-20260214-171605`
285
+ - Rendered smoke output roots:
286
+ - `C:\code\elementary-assertions-smoke-test\v0.1.2-pretag-smoke-20260214-171538\rendered`
287
+ - `C:\code\elementary-assertions-smoke-test\v0.1.2-posttag-smoke-20260214-171605\rendered`
288
+
289
+ ## v0.1.1 - 2026-02-14
290
+
291
+ ### Added
292
+ - Additional `runFromRelations` hardening checks for malformed accepted annotation internals:
293
+ - accepted dependency refs must point to known token ids
294
+ - accepted `TokenSelector` ids must point to known token ids
295
+ - accepted `TextPositionSelector` spans must be numeric and valid (`start <= end`)
296
+ - New negative contract tests for malformed accepted annotation internals.
297
+ - Dense benchmark scenario for `runFromRelations`:
298
+ - `npm run benchmark:core -- <iterations> dense`
299
+
300
+ ### Changed
301
+ - CI workflow now runs on Node `24` (matching dependency engine constraints).
302
+ - `test/fixtures` is tracked (`.gitkeep`) so repository layout checks are stable in CI.
303
+
304
+ ### Release Evidence
305
+ - Release commit: `378acc1d177cd3dbcd0c72dfccc83df7fdae7486`
306
+ - Tag: `v0.1.1`
307
+ - Smoke roots:
308
+ - `C:\code\elementary-assertions-smoke-test\v0.1.1-pretag-smoke-20260214-170352`
309
+ - `C:\code\elementary-assertions-smoke-test\v0.1.1-posttag-smoke-20260214-170418`
310
+ - Rendered smoke output roots:
311
+ - `C:\code\elementary-assertions-smoke-test\v0.1.1-pretag-smoke-20260214-170352\rendered`
312
+ - `C:\code\elementary-assertions-smoke-test\v0.1.1-posttag-smoke-20260214-170418\rendered`
313
+
314
+ ## v0.1.0 - 2026-02-14
315
+
316
+ ### Added
317
+ - Stable CommonJS package entry points:
318
+ - `require("elementary-assertions")`
319
+ - `require("elementary-assertions/validate")`
320
+ - `require("elementary-assertions/render")`
321
+ - `require("elementary-assertions/tools")`
322
+ - `require("elementary-assertions/schema")`
323
+ - Deterministic output contract with golden parity locks for:
324
+ - `access_control`
325
+ - `irs`
326
+ - `prime_factors`
327
+ - `prime_gen`
328
+ - `webshop`
329
+ - Strict CLI contract:
330
+ - exactly one of `--text` / `--in` for `run`
331
+ - strict booleans: `true|false` only
332
+ - explicit `--wti-timeout-ms`
333
+ - developer diagnostics gated behind global `--dev`
334
+ - Smoke-install release convention:
335
+ - clean installs in `C:\code\elementary-assertions-smoke-test\`
336
+ - one folder per install, including version + reason in the folder name
337
+
338
+ ### Changed
339
+ - Role-array model is authoritative (`arguments`, `modifiers`, `operators`).
340
+ - `schema_version` handling is strict:
341
+ - carried verbatim when present upstream
342
+ - omitted when absent upstream
343
+ - WTI health-check behavior is fixed and fail-fast (`GET /health`, HTTP `200` only, default timeout `2000ms`, no retries).
344
+
345
+ ### Removed / Rejected
346
+ - Legacy `assertions[*].slots` support across core, validate, render, and tooling.
347
+
348
+ ### Release Evidence
349
+ - Release commit: `d7b9eff643e3c118d32b9c3571597dea2388f98e`
350
+ - Tag: `v0.1.0`
351
+ - Smoke roots:
352
+ - `C:\code\elementary-assertions-smoke-test\v0.1.0-pretag-smoke-20260214-155509`
353
+ - `C:\code\elementary-assertions-smoke-test\v0.1.0-posttag-smoke-20260214-155534`
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 elementary-assertions contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # elementary-assertions
2
+
3
+ elementary-assertions is a deterministic, auditable assertion-construction layer for Node.js.
4
+
5
+ It converts accepted relations from `linguistic-enricher` into the first formal, assertion-centric meaning representation:
6
+
7
+ - predicate
8
+ - arguments (role-based)
9
+ - modifiers (role-based)
10
+ - operators
11
+ - evidence
12
+ - coverage and unresolved accounting
13
+
14
+ The library is conservative by design:
15
+ - no probabilistic inference
16
+ - no semantic guessing
17
+ - no hidden normalization
18
+
19
+ Its authoritative boundary ends at elementary assertions. Anything beyond this layer (concept models, norms, governance, domain interpretation) is explicitly downstream.
20
+
21
+ ## What this package is
22
+
23
+ elementary-assertions is an assertion compiler that sits directly after linguistic relation extraction.
24
+
25
+ It:
26
+ - runs (or consumes) accepted linguistic relations
27
+ - constructs elementary assertions with exactly one predicate
28
+ - persists a role-based model (arguments, modifiers, operators)
29
+ - preserves explicit evidence and provenance
30
+ - computes coverage and unresolved items instead of repairing gaps
31
+ - guarantees deterministic, replayable output
32
+
33
+ ## What this package is not
34
+
35
+ elementary-assertions deliberately does not:
36
+ - perform domain reasoning or business logic
37
+ - normalize predicates into semantic frames or ontologies
38
+ - invent missing roles or attachments
39
+ - infer facts beyond what is linguistically explicit
40
+ - convert output into normative keywords or policies
41
+ - depend on downstream ontologies or governance frameworks
42
+
43
+ ## Core principles
44
+
45
+ Deterministic
46
+ Determinism is mode-scoped:
47
+ - `runFromRelations(...)`: byte-identical output for identical `relationsSeed` and options, within the same `elementary-assertions` version.
48
+ - `runElementaryAssertions(...)`: byte-identical output only when all upstream inputs are fixed: identical text/options, pinned versions of `elementary-assertions` and `linguistic-enricher`, and stable WTI behavior for identical requests (service version, dataset state, and endpoint behavior).
49
+ Determinism is enforced by canonical identifiers, fixed ordering, schema validation, deterministic integrity validation, and golden/regression tests.
50
+
51
+ Conservative
52
+ If a structure cannot be projected deterministically, it is emitted as unresolved with explicit evidence. No silent repair.
53
+
54
+ Anchored
55
+ All spans are UTF-16 code-unit offsets (JavaScript slicing semantics). All references are token- and id-anchored.
56
+
57
+ Evidence-first
58
+ Assertions, roles, operators, suppression traces, and unresolved items carry explicit upstream evidence pointers.
59
+
60
+ Library-first
61
+ The core API is the authoritative interface. CLI and renderers are tooling that consume the same API and remain view-only.
62
+
63
+ ## Public API
64
+
65
+ ### runElementaryAssertions(text, options)
66
+
67
+ Runs the upstream linguistic pipeline and produces elementary assertions.
68
+
69
+ - Input: plain text
70
+ - Output: a single document with `stage: "elementary_assertions"` (schema-conformant)
71
+
72
+ WTI endpoint requirement
73
+ `runElementaryAssertions` requires a configured Wikipedia Title Index endpoint via `options.services["wikipedia-title-index"].endpoint`. If it is missing, execution fails explicitly.
74
+ After upstream execution, at least one positive WTI signal must be present in upstream token evidence; otherwise execution fails explicitly.
75
+
76
+ Example:
77
+
78
+ ```js
79
+ const { runElementaryAssertions } = require("elementary-assertions");
80
+
81
+ const doc = await runElementaryAssertions("A webshop is an online store.", {
82
+ services: {
83
+ "wikipedia-title-index": { endpoint: "http://localhost:3000" }
84
+ },
85
+ timeoutMs: 30000
86
+ });
87
+
88
+ console.log(doc.stage); // elementary_assertions
89
+ ```
90
+
91
+ ### runFromRelations(relationsSeed, options)
92
+
93
+ Builds elementary assertions from an already enriched upstream document (typically `relations_extracted` output).
94
+
95
+ This entry point:
96
+ - does not run the upstream pipeline
97
+ - does not require a WTI endpoint (WTI evidence is consumed if present in the provided seed)
98
+
99
+ Example:
100
+
101
+ ```js
102
+ const { runFromRelations } = require("elementary-assertions");
103
+
104
+ const doc = runFromRelations(relationsSeed, {});
105
+ ```
106
+
107
+ CLI replay mode (offline/deterministic input replay):
108
+
109
+ ```bash
110
+ npx elementary-assertions run --relations relations.yaml --out out.yaml
111
+ ```
112
+
113
+ ## Contract enforcement and view tooling
114
+
115
+ These modules are consumers of the core model.
116
+
117
+ Validation (schema + integrity checks):
118
+ ```js
119
+ const { validateElementaryAssertions } = require("elementary-assertions/validate");
120
+ validateElementaryAssertions(doc);
121
+ ```
122
+ Runtime validation currently enforces contract shape checks plus deterministic integrity invariants; determinism is additionally locked by regression and golden-reference tests.
123
+ Validation failures throw a `ValidationError` with a stable `code` field for contract-level error handling.
124
+
125
+ Validation scope distinction:
126
+ - Runtime validation: default library/CLI checks for shape, references, and deterministic integrity.
127
+ - Strict/dev validation: deeper semantic invariants than runtime validation, including diagnostics coherence and suppressed-assertion semantic consistency.
128
+ - Strict/dev diagnostics guarantees currently include:
129
+ - ordering/reference/coherence checks for diagnostics payloads
130
+ - suppressed-assertion semantic consistency checks
131
+ - coverage primary-set equality checks
132
+ - Additional diagnostics completeness hardening is tracked in `TODO.md` (strict/dev only, non-public tooling surface).
133
+
134
+ Dev/strict tooling boundary:
135
+ - Runtime guarantees are defined by the public API + runtime validation contract.
136
+ - Non-public `npm run dev:*` tooling is for maintainer triage and quality investigation.
137
+ - Dev tooling supports both artifact-reference diagnostics and optional upstream-context correlation/runtime probes for maintainers.
138
+ - Dev diagnostics include explicit enrichment views (for example upstream wikipedia field-path inventories and wiring attribution summaries) and may evolve between releases.
139
+ - Dev strict-check tooling (`npm run dev:check`) is triage-oriented: on failure it emits invariant-family context, a minimal reproducer pointer, and a suggested next diagnostics command.
140
+
141
+ Rendering (view-only, multiple layouts):
142
+ ```js
143
+ const { renderElementaryAssertions } = require("elementary-assertions/render");
144
+ const md = renderElementaryAssertions(doc, { format: "md", layout: "table" });
145
+ ```
146
+ Renderer contract scope:
147
+ - Contract-locked today via golden/parity tests:
148
+ - compact text (`format: "txt", layout: "compact"`)
149
+ - table markdown (`format: "md", layout: "table"`)
150
+ - meaning markdown (`format: "md", layout: "meaning"`)
151
+ - Other renderer combinations are currently best-effort and may evolve without contract change.
152
+ Release smoke renderer scope (install-time wiring checks):
153
+ - currently verified in smoke: `txt/compact`, `md/table`, `md/meaning`
154
+ - parity/golden suite remains the broader contract lock source (`txt/compact`, `md/table`, `md/meaning`)
155
+
156
+ Tooling (file I/O and CLI wiring):
157
+ ```js
158
+ const tools = require("elementary-assertions/tools");
159
+ ```
160
+ Advanced diagnostics tooling is intentionally non-public and exposed only via maintainer `npm run dev:*` workflows (not via public CLI flags).
161
+ Diagnostics reports are triage tooling and may evolve between releases.
162
+ Some diagnostics intentionally expose multiple interpretability lenses (for example clause-local vs segment-level) to aid investigation.
163
+ For WTI wiring diagnostics, runtime probe mode is authoritative; non-probe reports are summarized diagnostic views.
164
+
165
+ ## Output contract (summary)
166
+
167
+ - `stage` MUST be `elementary_assertions`
168
+ - `schema_version` is carried verbatim from the upstream seed schema when present; otherwise it is omitted
169
+ - `index_basis` MUST be:
170
+ - `text_field: canonical_text`
171
+ - `span_unit: utf16_code_units`
172
+ - persisted assertions MUST be role-based:
173
+ - `arguments[]` (always present, empty allowed)
174
+ - `modifiers[]` (always present, empty allowed)
175
+ - `operators[]` (always present, empty allowed)
176
+ - persisted assertions MUST NOT include legacy view-shaped fields:
177
+ - `assertions[*].slots`
178
+
179
+ Source provenance representation:
180
+ - Output includes `sources.inputs[]` and `sources.pipeline`.
181
+ - In-memory runs record `origin.kind: "in_memory"` artifacts (`seed.text.in_memory`, `relations_extracted.in_memory`).
182
+ - CLI file-origin runs (`--in`, `--relations`) preserve file provenance in `sources.inputs[]`:
183
+ - `artifact` reflects file input kind (`seed.txt` or `seed.relations.yaml`)
184
+ - `origin.kind: "file"` with absolute `origin.path` and source `origin.mtime_ms`
185
+
186
+ For full operational details (CLI commands, repo layout convenience, runner scripts, rendering defaults), see `docs/OPERATIONAL.md`.
187
+ For repository-only workflow policies (not package contract), see `docs/REPO_WORKFLOWS.md`.
188
+ For release and smoke-install workspace conventions (including `C:\code\elementary-assertions-smoke-test\`), see `docs/NPM_RELEASE.md`.
189
+ For non-public developer quality tooling (`npm run dev:*`), see `docs/DEV_TOOLING.md`.
190
+
191
+ ## Package entry points
192
+
193
+ - Core API: `require("elementary-assertions")`
194
+ - Validation: `require("elementary-assertions/validate")`
195
+ - Rendering: `require("elementary-assertions/render")`
196
+ - Tooling: `require("elementary-assertions/tools")`
197
+ - Schema asset (stable export): `require("elementary-assertions/schema")`
198
+
199
+ ## Documentation
200
+
201
+ - Agent constraints: `AGENTS.md`
202
+ - Operational guide: `docs/OPERATIONAL.md`
203
+ - Repository workflow policies: `docs/REPO_WORKFLOWS.md`
204
+ - Release flow: `docs/NPM_RELEASE.md`
205
+ - Developer tooling (non-public): `docs/DEV_TOOLING.md`
206
+ - Release notes template: `docs/RELEASE_NOTES_TEMPLATE.md`
207
+ - Changelog: `CHANGELOG.md`
208
+
209
+ ## License
210
+
211
+ MIT. See `LICENSE`.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ const { runCli } = require("../src/tools/cli");
3
+
4
+ runCli().catch((err) => {
5
+ const msg = err && err.message ? err.message : String(err);
6
+ process.stderr.write(`${msg}\n`);
7
+ process.exit(1);
8
+ });