htmlineage 0.0.0 → 0.1.0-beta.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/LICENSE +201 -0
- package/README.md +109 -3
- package/index.js +4 -0
- package/package.json +53 -3
- package/skills/htmlineage/SKILL.md +173 -0
- package/skills/htmlineage/references/example/.lineage/august-retention.json +167 -0
- package/skills/htmlineage/references/example/README.md +51 -0
- package/skills/htmlineage/references/example/august-retention.html +111 -0
- package/skills/htmlineage/references/format.md +218 -0
- package/skills/htmlineage/references/review.md +79 -0
- package/src/check/rules.js +421 -0
- package/src/check/summary.js +154 -0
- package/src/cli.js +99 -0
- package/src/commands/check.js +74 -0
- package/src/commands/index.js +7 -0
- package/src/commands/sql.js +65 -0
- package/src/commands/view.js +82 -0
- package/src/errors.js +39 -0
- package/src/graph/duplicates.js +78 -0
- package/src/graph/expr.js +56 -0
- package/src/graph/ids.js +24 -0
- package/src/graph/numbers.js +61 -0
- package/src/graph/parse.js +196 -0
- package/src/graph/schema.js +491 -0
- package/src/graph/trace.js +45 -0
- package/src/help.js +25 -0
- package/src/html/embed.js +142 -0
- package/src/html/page.js +101 -0
- package/src/meta.js +13 -0
- package/src/sql/compose.js +215 -0
- package/src/sql/style.js +193 -0
- package/src/viewer/client/bridge.js +143 -0
- package/src/viewer/client/favicon.svg +6 -0
- package/src/viewer/client/fonts/JetBrainsMono-Bold.woff2 +0 -0
- package/src/viewer/client/fonts/JetBrainsMono-Medium.woff2 +0 -0
- package/src/viewer/client/fonts/JetBrainsMono-Regular.woff2 +0 -0
- package/src/viewer/client/fonts/JetBrainsMono-SemiBold.woff2 +0 -0
- package/src/viewer/client/fonts/OFL-JetBrainsMono.txt +93 -0
- package/src/viewer/client/fonts/OFL-SourceSerif4.txt +93 -0
- package/src/viewer/client/fonts/SourceSerif4-Medium.woff2 +0 -0
- package/src/viewer/client/fonts/SourceSerif4-Regular.woff2 +0 -0
- package/src/viewer/client/fonts/SourceSerif4-SemiBold.woff2 +0 -0
- package/src/viewer/client/index.html +95 -0
- package/src/viewer/client/lineage.js +674 -0
- package/src/viewer/client/themes.css +76 -0
- package/src/viewer/client/viewer.css +1420 -0
- package/src/viewer/client/viewer.js +765 -0
- package/src/viewer/payload.js +45 -0
- package/src/viewer/server.js +188 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Varun Jain
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
|
-
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset=".github/assets/logo-dark.svg">
|
|
3
|
+
<img src=".github/assets/logo-light.svg" alt="htmlineage" width="420">
|
|
4
|
+
</picture>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
**A provenance layer for AI-generated reports.** Every number, chart, and claim traces back to the query that produced it.
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
<picture>
|
|
9
|
+
<source media="(prefers-color-scheme: dark)" srcset=".github/assets/viewer-dark.png">
|
|
10
|
+
<img src=".github/assets/viewer-light.png" alt="The htmlineage viewer: a quarterly business review on the left, and on the right how its "Gap to year-end target" figure was computed">
|
|
11
|
+
</picture>
|
|
12
|
+
|
|
13
|
+
<sub>The viewer on a sample report. Halden is a fictional company and its data is made up.</sub>
|
|
14
|
+
|
|
15
|
+
AI writes analytics reports faster than data teams can vet them. htmlineage records where each figure came from — `source → view → figure → insight` — so a reviewer can see the lineage behind any claim before it reaches a CXO deck. A skill teaches your AI assistant to record that lineage while it builds a report, and a small CLI checks it, composes it into one SQL script, and shows it beside the report.
|
|
16
|
+
|
|
17
|
+
- **Visibility, not verification.** htmlineage shows the lineage; it doesn't assert the numbers are right.
|
|
18
|
+
- **Zero builder friction.** Reports stay plain `.html`. Lineage rides along in an inert `<script type="application/lineage+json">` block and `data-lineage` attributes — invisible to the reader.
|
|
19
|
+
- **SQL-first evidence.** Compose an entire report back into one runnable SQL script for review.
|
|
20
|
+
- **Pinned time.** Queries use absolute date ranges, never `now()`, so a report reproduces exactly.
|
|
21
|
+
|
|
22
|
+
## Status
|
|
23
|
+
|
|
24
|
+
**Beta.** The lineage format may still change before `0.1.0`.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
**The skill** follows the open [Agent Skills](https://agentskills.io) standard, so it works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot and other tools that read skills. Install it with [skills.sh](https://skills.sh):
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx skills add htmlineage/htmlineage -s htmlineage
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or copy [`skills/htmlineage/`](skills/htmlineage/) into your tool's skills folder (for example `.claude/skills/` for Claude Code, `.agents/skills/` for most others).
|
|
35
|
+
|
|
36
|
+
The skill is opt-in: your assistant uses it when you ask for a report that will be reviewed, traced or shared with leadership, and not for quick questions. To use it for every report in a repository, add a line such as "Every report built here uses htmlineage" to the instructions file your tool reads (`AGENTS.md`, `CLAUDE.md` or similar).
|
|
37
|
+
|
|
38
|
+
**The CLI** needs Node 18 or later and nothing else. There is nothing to install: run it with `npx`.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx htmlineage --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Build and check a report
|
|
45
|
+
|
|
46
|
+
### 1. Ask for a report
|
|
47
|
+
|
|
48
|
+
Tell your assistant you want a report that will be reviewed, traced or shared with leadership. The assistant writes the report as plain HTML and, beside it, the lineage graph in `.lineage/<report>.json`.
|
|
49
|
+
|
|
50
|
+
### 2. Check it
|
|
51
|
+
|
|
52
|
+
This validates the graph against the report, embeds it into the HTML, and prints a summary. It exits `0` when the report passes (warnings still pass) and `1` when it does not.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx htmlineage check report.html
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
It reads the graph from `.lineage/<report>.json` beside the report, or else the block already embedded in the report; `--graph <path>` reads that file instead. Use `--no-embed` to leave the file untouched and `--json` for machine-readable output. The rules and what each message means are in [CHECKS.md](https://github.com/htmlineage/htmlineage/blob/main/CHECKS.md).
|
|
59
|
+
|
|
60
|
+
### 3. Open it
|
|
61
|
+
|
|
62
|
+
This serves a two-pane page on 127.0.0.1: the report on the left, the lineage of whatever you click on the right.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx htmlineage view report.html
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 4. Compose the SQL
|
|
69
|
+
|
|
70
|
+
This joins every source, view, and figure into a single script a reviewer can paste into the warehouse. A report that fails `check` is refused.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx htmlineage sql report.html > report.sql
|
|
74
|
+
npx htmlineage sql report.html --id f3 > f3.sql
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`--id <node>` composes only that node and everything it rests on.
|
|
78
|
+
|
|
79
|
+
Each command has its own options: run `npx htmlineage <command> --help`.
|
|
80
|
+
|
|
81
|
+
## Review a report
|
|
82
|
+
|
|
83
|
+
To review a report someone else built, ask your assistant to review it. The skill then follows [the review guide](skills/htmlineage/references/review.md): read the check summary, trace the numbers that carry the report, and say where the evidence is weak.
|
|
84
|
+
|
|
85
|
+
To do it yourself, run `check`, click through the report in `view`, and run `sql --id` on the numbers that matter.
|
|
86
|
+
|
|
87
|
+
`view` serves the report, its graph and files beside the report such as images, only on 127.0.0.1. It never serves any other file whose name starts with a dot or that lies outside the report's folder, and it needs no database or credentials. More in [SECURITY.md](SECURITY.md).
|
|
88
|
+
|
|
89
|
+
## How lineage is recorded
|
|
90
|
+
|
|
91
|
+
A report's graph is a JSON object with a `nodes` map. Each node is one of four steps:
|
|
92
|
+
|
|
93
|
+
| Step | Id | What it is |
|
|
94
|
+
| ----------- | --- | ----------------------------------------------------------------------- |
|
|
95
|
+
| **source** | `q` | One wide query per dataset, with a pinned date range |
|
|
96
|
+
| | `x` | An external source htmlineage cannot see inside (a CSV, a document) |
|
|
97
|
+
| **view** | `v` | A `select` over sources or views, shown as a table or chart |
|
|
98
|
+
| **figure** | `f` | A single value picked from a view, or a SQL expression over figures |
|
|
99
|
+
| **insight** | `i` | A claim resting on views, figures or insights, or flagged as ungrounded |
|
|
100
|
+
|
|
101
|
+
Elements on the page point at nodes:
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<div class="kpi-value" data-lineage="f1">46.6%</div>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Every field of every step is in the [field reference](skills/htmlineage/references/format.md), and a complete short report with its graph is in the [worked example](skills/htmlineage/references/example/).
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
Apache-2.0 © Varun Jain
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htmlineage",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "A provenance layer for AI-generated reports — every number, chart, and claim traces back to the query that produced it.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"htmlineage": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"src/",
|
|
13
|
+
"skills/"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "node --test test/*.test.js",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"lint:fix": "eslint . --fix",
|
|
22
|
+
"format": "prettier --write .",
|
|
23
|
+
"format:check": "prettier --check .",
|
|
24
|
+
"check:package": "node scripts/check-package.mjs",
|
|
25
|
+
"start": "node index.js"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"htmlineage",
|
|
29
|
+
"provenance",
|
|
30
|
+
"lineage",
|
|
31
|
+
"data-lineage",
|
|
32
|
+
"sql",
|
|
33
|
+
"reporting",
|
|
34
|
+
"analytics",
|
|
35
|
+
"ai"
|
|
36
|
+
],
|
|
5
37
|
"author": "Varun Jain <varunjainvj1@gmail.com>",
|
|
6
|
-
"license": "Apache-2.0"
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/htmlineage/htmlineage.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/htmlineage/htmlineage/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/htmlineage/htmlineage#readme",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@commitlint/cli": "^19.6.1",
|
|
49
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
50
|
+
"@eslint/js": "^9.17.0",
|
|
51
|
+
"eslint": "^9.17.0",
|
|
52
|
+
"prettier": "^3.4.2"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"node-html-parser": "^7.1.0"
|
|
56
|
+
}
|
|
7
57
|
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: htmlineage
|
|
3
|
+
description: Records where every number in an HTML data report came from, so a reviewer can trace each figure, chart and claim back to the query behind it. Use when the user asks for a report that will be reviewed, traced or shared with leadership, asks for lineage or htmlineage by name, or when project instructions say reports use htmlineage. Also use to review such a report or explain how one of its numbers was computed. Skip it for quick, throwaway analysis unless asked.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# htmlineage
|
|
7
|
+
|
|
8
|
+
While you build a report, you also write down how each thing on the page was
|
|
9
|
+
made: which query, which step, which value. That record is the lineage graph.
|
|
10
|
+
`htmlineage check` validates it and embeds it in the report. A reviewer can
|
|
11
|
+
then open any number and see the SQL behind it.
|
|
12
|
+
|
|
13
|
+
This changes nothing about how you query, chart or write. The report looks the
|
|
14
|
+
same with or without it. You add the graph and you run `check`.
|
|
15
|
+
|
|
16
|
+
## When to use it
|
|
17
|
+
|
|
18
|
+
Use it when the report will be reviewed before it is shared: the user says so,
|
|
19
|
+
asks for lineage or htmlineage, or the project's instructions say every report
|
|
20
|
+
there uses it. Do not use it for a quick look at some data, or when the user
|
|
21
|
+
says they do not need it. When you are unsure, ask once.
|
|
22
|
+
|
|
23
|
+
## The shape
|
|
24
|
+
|
|
25
|
+
Every value reaches the page by one path:
|
|
26
|
+
|
|
27
|
+
1. **Source.** Pull once, wide, per mart: one query per dataset, with the
|
|
28
|
+
reporting period as literal dates.
|
|
29
|
+
2. **View.** Make a view for everything you show: each chart and each table
|
|
30
|
+
is a SELECT over sources or other views.
|
|
31
|
+
3. **Figure.** Pick each number from a view: one cell. Or derive it from other
|
|
32
|
+
figures with an expression.
|
|
33
|
+
4. **Insight.** Write each claim over the figures, views and insights it
|
|
34
|
+
rests on.
|
|
35
|
+
|
|
36
|
+
If a claim rests on nothing you queried, keep it and mark it ungrounded. Never
|
|
37
|
+
leave it out to make the report look cleaner.
|
|
38
|
+
|
|
39
|
+
## Workflow
|
|
40
|
+
|
|
41
|
+
1. Query the warehouse the way you normally would. Write each source into the
|
|
42
|
+
graph as you run it.
|
|
43
|
+
2. Write the graph to `.lineage/<report-stem>.json`, beside the report. For
|
|
44
|
+
`growth-review.html` that is `.lineage/growth-review.json`. Add views,
|
|
45
|
+
figures and insights to it as you build the page, not at the end.
|
|
46
|
+
3. Put `data-lineage="<id>"` on every element that shows a view, figure or
|
|
47
|
+
insight. A number inside a sentence gets its own span.
|
|
48
|
+
4. Run `npx htmlineage check <report>.html`.
|
|
49
|
+
5. Fix every error. Most messages end with what to change. Run `check` again.
|
|
50
|
+
6. Fix the warnings you can. A warning does not fail the report, but each one
|
|
51
|
+
is something a reviewer will see.
|
|
52
|
+
7. When you edit the page after this, update the graph to match and run
|
|
53
|
+
`check` again. It is the last thing you do before you hand the report over.
|
|
54
|
+
|
|
55
|
+
`check` exits 0 when the report passes, with or without warnings, and 1 when
|
|
56
|
+
it does not. Exit 2 means the command was wrong (a bad flag, or no report
|
|
57
|
+
named): fix the command, not the graph. Never write the embedded
|
|
58
|
+
`<script>` block yourself; `check` does.
|
|
59
|
+
|
|
60
|
+
## Pin time
|
|
61
|
+
|
|
62
|
+
Every source names its period with literal dates, both in `period` and in its
|
|
63
|
+
SQL:
|
|
64
|
+
|
|
65
|
+
```sql
|
|
66
|
+
where order_date between '2026-08-01' and '2026-08-31'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Never use `current_date`, `now()`, `dateadd(…, current_date)` or "last 30
|
|
70
|
+
days". A report must give the same numbers when it is run again next month.
|
|
71
|
+
|
|
72
|
+
## Patterns
|
|
73
|
+
|
|
74
|
+
- **Ranks.** Add a `rank() over (…)` column to the view already on the page,
|
|
75
|
+
then pick the rank as a figure. Do not make a separate unbound view for it.
|
|
76
|
+
- **Shares.** Pick from the view on the page with a subquery in the figure's
|
|
77
|
+
SQL, for example a channel's count over the total, when no shown view has
|
|
78
|
+
the share as a column.
|
|
79
|
+
- **A change or a ratio.** A figure with `expr` over other figures, such as
|
|
80
|
+
`(f1 - f2) / f2`. It has no `sql`.
|
|
81
|
+
- **A change in a rate.** When a percentage moves, say whether the change is
|
|
82
|
+
in points or relative: "up 4.9 points" or "a relative gain of 11.8%", never
|
|
83
|
+
a bare "up 11.8%".
|
|
84
|
+
- **A name.** A figure can hold text, such as the top channel's name. Its
|
|
85
|
+
`value` and `display` are the name.
|
|
86
|
+
- **A number you were told.** When someone hands you a number or a file (a
|
|
87
|
+
target, a forecast, a CSV), make an external source with `given` saying what
|
|
88
|
+
you were handed and by whom. Put a figure over it, and bind the figure. Never
|
|
89
|
+
bind the source.
|
|
90
|
+
- **Copy `display` exactly.** The span's text is the figure's `display`,
|
|
91
|
+
character for character: `46.6%`, not `46.60%` or `47%`.
|
|
92
|
+
- **Metric names.** Write `30-day retention`, not "retention over 30 days".
|
|
93
|
+
`check` reads a number joined to a time unit by a hyphen as part of a
|
|
94
|
+
definition, not a claim to trace.
|
|
95
|
+
- **Opinion and forecast.** A claim from judgement or outside knowledge is an
|
|
96
|
+
insight with `"ungrounded": true` and `"from": []`. Ungrounded means no data
|
|
97
|
+
backs it. A projection you can compute from figures, such as "at this pace
|
|
98
|
+
we end the year at $1.47M", is an `expr` figure and the claim rests on it.
|
|
99
|
+
- **Every number a claim leans on.** If a claim depends on a quantity, that
|
|
100
|
+
quantity is a figure shown on the page and the claim rests on it. "All of
|
|
101
|
+
the growth came from new customers" needs new MRR on the page, not only the
|
|
102
|
+
totals beside it.
|
|
103
|
+
|
|
104
|
+
## Describe each step
|
|
105
|
+
|
|
106
|
+
Sql sources, views and figures carry a `desc`: one line, 120 characters at
|
|
107
|
+
most, saying how the step was computed. A reviewer reads it before the SQL.
|
|
108
|
+
|
|
109
|
+
- Use business words. Name the population, the filter and the time window.
|
|
110
|
+
- No result values: the desc says how, not what came out.
|
|
111
|
+
- No SQL words: no `select`, `join`, column names or table names.
|
|
112
|
+
|
|
113
|
+
| Step | Good | Bad |
|
|
114
|
+
| ------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
115
|
+
| sql source | Retention by channel and cohort month, January to August 2026 | select channel, retention_30d from marts.retention_by_channel |
|
|
116
|
+
| view | Average 30-day retention for each channel and month, ranked within each month | Retention by channel, paid social leads at 46.6% |
|
|
117
|
+
| figure with `sql` | Paid social's 30-day retention for the August 2026 cohort | Pick from v1 where channel = paid_social |
|
|
118
|
+
| figure with `expr` | Change in paid social retention from July to August, relative to July | (f1 - f2) / f2 |
|
|
119
|
+
|
|
120
|
+
A figure's `label` is what the number _is_ ("Paid social retention,
|
|
121
|
+
August"). Its `desc` is how it was _computed_.
|
|
122
|
+
|
|
123
|
+
## SQL style
|
|
124
|
+
|
|
125
|
+
The composed SQL is what a reviewer reads, so write it to be read:
|
|
126
|
+
|
|
127
|
+
- Lowercase keywords, one clause per line, one column per line.
|
|
128
|
+
- Name every computed column: `avg(retention_30d) as retention`.
|
|
129
|
+
- Aliases of three letters or more.
|
|
130
|
+
- A view or figure names its parents by id, as table names: `from q1`,
|
|
131
|
+
`from v2`.
|
|
132
|
+
- List columns. No `select *`.
|
|
133
|
+
|
|
134
|
+
## Don't
|
|
135
|
+
|
|
136
|
+
- Give a figure its own query against the warehouse. It picks from a view or
|
|
137
|
+
source that is already there.
|
|
138
|
+
- Leave a number in prose outside a `data-lineage` span.
|
|
139
|
+
- Use `current_date` or any relative date, anywhere.
|
|
140
|
+
- Chain views deeply. Each link is one more thing a reviewer has to read;
|
|
141
|
+
two deep is usually enough.
|
|
142
|
+
- Drop a claim you cannot source. Mark it ungrounded instead.
|
|
143
|
+
|
|
144
|
+
## When asked how a number was computed
|
|
145
|
+
|
|
146
|
+
For a number, chart or claim in a report, your own or one you were handed,
|
|
147
|
+
take the id from the element's `data-lineage` attribute and run:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
npx htmlineage sql <report>.html --id <id>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
It prints one runnable script: the source, every view and the figure, in
|
|
154
|
+
order. Answer from that script rather than by reading the graph by hand.
|
|
155
|
+
`npx htmlineage view <report>.html` opens the report beside its lineage for a
|
|
156
|
+
person to click through.
|
|
157
|
+
|
|
158
|
+
## When asked to review a report
|
|
159
|
+
|
|
160
|
+
Follow [references/review.md](references/review.md). In short: read the check
|
|
161
|
+
summary with `--no-embed`, trace the numbers the report rests on with
|
|
162
|
+
`sql --id`, and report what is weak. Do not edit the report.
|
|
163
|
+
|
|
164
|
+
## References
|
|
165
|
+
|
|
166
|
+
- [references/format.md](references/format.md): every field of every kind of
|
|
167
|
+
node, what may rest on what, ids, and binding. Open it when you write your
|
|
168
|
+
first graph, or when `check` names a field you do not recognise.
|
|
169
|
+
- [references/example/](references/example/): a complete short report with
|
|
170
|
+
its graph, the order it was built in, and the `check` output it gives. Read
|
|
171
|
+
it before your first report; copy its shape.
|
|
172
|
+
- [references/review.md](references/review.md): how to review a report
|
|
173
|
+
someone else built. Open it only when asked to review.
|