@codyswann/lisa 2.221.6 → 2.222.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 (69) hide show
  1. package/dist/utils/usage-accounting.d.ts +3 -1
  2. package/dist/utils/usage-accounting.d.ts.map +1 -1
  3. package/dist/utils/usage-accounting.js +142 -47
  4. package/dist/utils/usage-accounting.js.map +1 -1
  5. package/package.json +1 -1
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/skills/lisa-usage-accounting/SKILL.md +12 -0
  9. package/plugins/lisa/rules/eager/usage-accounting.md +7 -2
  10. package/plugins/lisa/rules/reference/usage-accounting.md +47 -5
  11. package/plugins/lisa/skills/lisa-usage-accounting/SKILL.md +12 -0
  12. package/plugins/lisa-agy/plugin.json +1 -1
  13. package/plugins/lisa-agy/skills/lisa-usage-accounting/SKILL.md +12 -0
  14. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  15. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  17. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-copilot/rules/eager/usage-accounting.md +7 -2
  21. package/plugins/lisa-copilot/rules/reference/usage-accounting.md +47 -5
  22. package/plugins/lisa-copilot/skills/lisa-usage-accounting/SKILL.md +12 -0
  23. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cursor/rules/usage-accounting-reference.mdc +47 -5
  25. package/plugins/lisa-cursor/rules/usage-accounting.mdc +7 -2
  26. package/plugins/lisa-cursor/skills/lisa-usage-accounting/SKILL.md +12 -0
  27. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-agy/plugin.json +1 -1
  30. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  35. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  39. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  40. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  44. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  45. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  49. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  50. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  54. package/plugins/lisa-rails-agy/plugin.json +1 -1
  55. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  59. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  60. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  64. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  65. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  67. package/plugins/src/base/rules/eager/usage-accounting.md +7 -2
  68. package/plugins/src/base/rules/reference/usage-accounting.md +47 -5
  69. package/plugins/src/base/skills/lisa-usage-accounting/SKILL.md +12 -0
@@ -67,6 +67,13 @@ and artifact refs. Callers do not get to omit the "unavailable" case; when trust
67
67
  missing they still pass an explicit entry with `source: unavailable` and nullable token/cost
68
68
  fields.
69
69
 
70
+ When the runtime exposes only a trustworthy subtotal, callers MUST use `source: measured-subset`,
71
+ write the subtotal to `measured_subset_tokens`, and leave `total_tokens: null`. Do not coerce a
72
+ known subset into `total_tokens`; rollups use `total_tokens` only for complete totals. The
73
+ `measured_subset_tokens` field is optional for backward compatibility with callers that construct
74
+ ordinary observed, estimated, or unavailable entries; the shared serializer normalizes omission
75
+ to `null`. A trustworthy whole-run cost remains valid independently of incomplete token telemetry.
76
+
70
77
  ## Return shape
71
78
 
72
79
  Return structured output so callers can persist or log what happened without reparsing prose:
@@ -164,6 +171,11 @@ failures into a generic "usage update failed."
164
171
  canonical `usage-accounting` rule.
165
172
  - Never append a second `## Lisa Usage` section or a second managed usage comment.
166
173
  - Never treat missing usage as zero. Callers must record explicit `source: unavailable` entries.
174
+ - Never add a measured subset to complete token totals. A mixed complete-plus-measured-subset
175
+ direct or child scope has `null` token rollups, while trustworthy whole-run cost rolls up
176
+ independently.
177
+ - Never discard the optional child-token incompleteness state parsed from an existing rollup when
178
+ `child_refs` were not refreshed. Preserve it through ordinary direct-entry rewrites.
167
179
  - Never skip rollup dedupe. Child totals are keyed by stable `entry_id`, not by child ref count.
168
180
  - Never silently drop to comments. Return `outcome: comment-fallback` so the caller can surface the
169
181
  writable surface that actually holds the ledger.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -16,7 +16,8 @@ Every artifact with inline body content gets exactly one section:
16
16
 
17
17
  Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is the stable dedupe key — rewriting the same logical run with the same `entry_id` updates in place; a different run gets a different `entry_id`.
18
18
 
19
- - **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `unavailable`.
19
+ - **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `measured-subset` (a trustworthy subtotal exists, but the complete run total is unknown) / `unavailable`.
20
+ - **`measured_subset_tokens`**: optional measured subtotal for `measured-subset` entries only. Omission is normalized to `null` for backward-compatible callers. Keep `total_tokens = null` so rollups do not treat a subset as a complete total.
20
21
  - **`pricing_status`**: same trinary plus `missing` (cost not known but should be).
21
22
  - **Absence ≠ zero.** `null` means unknown; `0` means explicitly zero. Always write the entry — never silently omit.
22
23
  - Do NOT replace observed counts with estimates.
@@ -25,4 +26,8 @@ Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is th
25
26
 
26
27
  Container artifacts (Epic, PRD, etc.) roll up usage from their direct children. Roll-up is recursive — a parent's `## Lisa Usage` aggregates its descendants' direct entries. Re-writes are idempotent: re-running an intake or lifecycle skill must not duplicate entries.
27
28
 
28
- Full schema (all 17 fields, pricing semantics, rollup math, idempotent-rewrite rules): [reference/usage-accounting.md](../reference/usage-accounting.md).
29
+ Measured-child incompleteness is durable across ordinary rewrites through the optional
30
+ `lisa:usage-rollup-token-status` extension. Do not infer completeness merely because a rewrite did
31
+ not re-fetch child ledgers.
32
+
33
+ Full schema (backward-compatible 17-field primary marker, correlated measured-subset extension, pricing semantics, rollup math, idempotent-migration rules): [reference/usage-accounting.md](../reference/usage-accounting.md).
@@ -25,12 +25,13 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
25
25
  | `run_id` | Runtime/session identifier when available; empty only when the runtime exposes no stable run id. |
26
26
  | `provider` | Model provider name. |
27
27
  | `model` | Model identifier. |
28
- | `source` | `observed`, `estimated`, or `unavailable`. |
28
+ | `source` | `observed`, `estimated`, `measured-subset`, or `unavailable`. |
29
29
  | `input_tokens` | Prompt/input tokens, or `null` when unavailable. |
30
30
  | `cached_input_tokens` | Cached/reused input tokens, or `null` when unavailable/not exposed. |
31
31
  | `output_tokens` | Output/completion tokens, or `null` when unavailable. |
32
32
  | `reasoning_tokens` | Reasoning/internal tokens, or `null` when unavailable/not exposed. |
33
33
  | `total_tokens` | Total trustworthy tokens for the entry, or `null`. |
34
+ | `measured_subset_tokens` | Optional trustworthy measured subtotal for a known subset of the run. Omission is normalized to `null` so callers written before this field remain source-compatible. |
34
35
  | `cost` | Observed or estimated cost for this entry, or `null`. |
35
36
  | `currency` | ISO currency code when `cost` is known, otherwise `null`. |
36
37
  | `pricing_status` | `observed`, `estimated`, `missing`, or `unavailable`. |
@@ -46,13 +47,17 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
46
47
 
47
48
  - `observed`: the runtime supplied the usage directly. Do not replace observed counts with estimates.
48
49
  - `estimated`: Lisa derived counts or cost from trustworthy runtime metadata plus an explicit pricing contract. Estimates are allowed only when the derivation inputs are real and attributable to the run.
50
+ - `measured-subset`: Lisa measured a known subset of the run, but not enough to claim a complete `total_tokens` value. Preserve the subtotal in `measured_subset_tokens`, keep `total_tokens = null`, and keep rollup totals unknown instead of treating the subset as the whole run.
49
51
  - `unavailable`: Lisa could not obtain trustworthy usage data. Write the entry anyway with `null` token/cost fields rather than silently omitting the row.
50
52
 
51
53
  The absence of data is never treated as zero. `null` means unknown; `0` means explicitly observed or derived zero.
52
54
 
53
55
  For example, an unavailable Verify run still records a direct entry with `source = unavailable`,
54
56
  `pricing_status = unavailable`, and `null` token/cost fields so downstream readers can distinguish
55
- "missing telemetry" from "zero usage."
57
+ "missing telemetry" from "zero usage." A Plan run with measured sub-agent usage but unmeasured
58
+ main-loop usage records `source = measured-subset`, `measured_subset_tokens = <subtotal>`, and
59
+ `total_tokens = null` so the subtotal is durable without being misrepresented as the complete run
60
+ total.
56
61
 
57
62
  ## Pricing semantics
58
63
 
@@ -64,16 +69,34 @@ For example, an unavailable Verify run still records a direct entry with `source
64
69
  - `unavailable`: the runtime exposed neither trustworthy cost nor enough trustworthy token data to estimate cost.
65
70
 
66
71
  Runtime-observed cost always wins over estimates. Estimated cost never overwrites an observed value. Missing pricing preserves token counts and a `null` cost.
72
+ Token completeness and cost trust are independent: a `measured-subset` entry may still carry an
73
+ observed trustworthy whole-run cost. Token rollups remain unknown, but that cost participates in
74
+ cost rollups under the normal pricing and currency rules.
67
75
 
68
76
  ## Machine-readable tokens
69
77
 
70
- Every visible direct entry row ends with exactly one machine-readable token:
78
+ Every visible direct entry row contains the backward-compatible 17-field primary token:
71
79
 
72
80
  ```text
73
81
  <!-- lisa:usage-entry entry_id=<id> flow=<flow> run_id=<run-id> provider=<provider> model=<model> source=<source> input_tokens=<n|null> cached_input_tokens=<n|null> output_tokens=<n|null> reasoning_tokens=<n|null> total_tokens=<n|null> cost=<decimal|null> currency=<code|null> pricing_status=<status> pricing_source=<ref|null> artifact_ref=<ref> parent_artifact_ref=<ref-or-empty> -->
74
82
  ```
75
83
 
76
- Field order is fixed. A reader parses the usage ledger by matching `<!-- lisa:usage-entry ` lines only; it never needs to scrape prose or table cell positions. String fields are percent-encoded before rendering and decoded after parsing, so whitespace, commas, and HTML comment terminators inside source values cannot split or truncate the token.
84
+ The row immediately follows it with a correlated measured-subset extension. Writers serialize an
85
+ omitted value as `null` instead of `undefined`:
86
+
87
+ ```text
88
+ <!-- lisa:usage-entry-measured-subset entry_id=<id> measured_subset_tokens=<n|null> -->
89
+ ```
90
+
91
+ The primary field order is fixed and deliberately matches the pre-measured-subset contract so
92
+ legacy 17-field readers continue to enumerate entries. Current readers correlate the extension by
93
+ its percent-encoded `entry_id`. They also accept the `@codyswann/lisa@2.222.0` transitional marker,
94
+ which placed `measured_subset_tokens` between `total_tokens` and `cost`, and migrate it to the
95
+ primary-plus-extension layout on rewrite. Only that transitional additive field accepts the literal
96
+ `undefined` emitted by an older caller and normalizes it to `null`; established numeric fields
97
+ remain strict. String fields are percent-encoded before rendering and decoded after parsing, so
98
+ whitespace, commas, and HTML comment terminators inside source values cannot split or truncate the
99
+ token.
77
100
 
78
101
  Every managed section also ends with exactly one rollup token:
79
102
 
@@ -86,6 +109,23 @@ Every managed section also ends with exactly one rollup token:
86
109
  - `child_refs` enumerates the child artifacts consulted for the rollup.
87
110
  - `total_*` fields equal direct plus child totals over the deduped entry set.
88
111
 
112
+ If a direct entry or freshly resolved child entry is `measured-subset`, the corresponding token
113
+ scope and combined `total_tokens` are `null`; a measured subtotal is never added to complete token
114
+ counts. Other established nullable-entry behavior is unchanged. Cost rollups are computed
115
+ independently, so a trustworthy whole-run cost is not discarded merely because token completeness
116
+ is unknown.
117
+
118
+ When freshly resolved child work contains a measured subset, the primary rollup token is followed
119
+ by this optional backward-compatible extension:
120
+
121
+ ```text
122
+ <!-- lisa:usage-rollup-token-status child_tokens_incomplete=true -->
123
+ ```
124
+
125
+ The extension preserves child-token incompleteness across ordinary direct-entry rewrites that do
126
+ not resolve children again. It is omitted when child token totals are not known to be incomplete,
127
+ so legacy rollup objects and readers retain their established shape.
128
+
89
129
  The rollup token is the machine-readable summary. The visible rollup table mirrors it for humans. List fields are comma-delimited after encoding each item independently; commas inside an item are encoded as data, not treated as separators.
90
130
 
91
131
  ## Visible rendering contract
@@ -138,7 +178,9 @@ The rollup contract is additive across the hierarchy: PRDs may roll up Epics/Sto
138
178
  - Recompute the entire section on every write; never append ad hoc rows.
139
179
  - Sort direct entries deterministically by `(flow, run_id, entry_id)`.
140
180
  - Preserve existing entries with unchanged `entry_id` and refreshed field values.
141
- - Re-running with the same logical entry set must produce byte-identical output.
181
+ - Re-running with the same logical entry set must produce byte-identical output. Rewriting a legacy
182
+ primary-only marker or the 2.222.0 transitional marker migrates once to the canonical
183
+ primary-plus-extension layout; subsequent rewrites are byte-identical.
142
184
  - Do not include timestamps in the section preamble or token lines.
143
185
 
144
186
  Idempotency is enforced by `entry_id` for direct entries and by the fixed rollup token field order for totals.
@@ -67,6 +67,13 @@ and artifact refs. Callers do not get to omit the "unavailable" case; when trust
67
67
  missing they still pass an explicit entry with `source: unavailable` and nullable token/cost
68
68
  fields.
69
69
 
70
+ When the runtime exposes only a trustworthy subtotal, callers MUST use `source: measured-subset`,
71
+ write the subtotal to `measured_subset_tokens`, and leave `total_tokens: null`. Do not coerce a
72
+ known subset into `total_tokens`; rollups use `total_tokens` only for complete totals. The
73
+ `measured_subset_tokens` field is optional for backward compatibility with callers that construct
74
+ ordinary observed, estimated, or unavailable entries; the shared serializer normalizes omission
75
+ to `null`. A trustworthy whole-run cost remains valid independently of incomplete token telemetry.
76
+
70
77
  ## Return shape
71
78
 
72
79
  Return structured output so callers can persist or log what happened without reparsing prose:
@@ -164,6 +171,11 @@ failures into a generic "usage update failed."
164
171
  canonical `usage-accounting` rule.
165
172
  - Never append a second `## Lisa Usage` section or a second managed usage comment.
166
173
  - Never treat missing usage as zero. Callers must record explicit `source: unavailable` entries.
174
+ - Never add a measured subset to complete token totals. A mixed complete-plus-measured-subset
175
+ direct or child scope has `null` token rollups, while trustworthy whole-run cost rolls up
176
+ independently.
177
+ - Never discard the optional child-token incompleteness state parsed from an existing rollup when
178
+ `child_refs` were not refreshed. Preserve it through ordinary direct-entry rewrites.
167
179
  - Never skip rollup dedupe. Child totals are keyed by stable `entry_id`, not by child ref count.
168
180
  - Never silently drop to comments. Return `outcome: comment-fallback` so the caller can surface the
169
181
  writable surface that actually holds the ledger.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -30,12 +30,13 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
30
30
  | `run_id` | Runtime/session identifier when available; empty only when the runtime exposes no stable run id. |
31
31
  | `provider` | Model provider name. |
32
32
  | `model` | Model identifier. |
33
- | `source` | `observed`, `estimated`, or `unavailable`. |
33
+ | `source` | `observed`, `estimated`, `measured-subset`, or `unavailable`. |
34
34
  | `input_tokens` | Prompt/input tokens, or `null` when unavailable. |
35
35
  | `cached_input_tokens` | Cached/reused input tokens, or `null` when unavailable/not exposed. |
36
36
  | `output_tokens` | Output/completion tokens, or `null` when unavailable. |
37
37
  | `reasoning_tokens` | Reasoning/internal tokens, or `null` when unavailable/not exposed. |
38
38
  | `total_tokens` | Total trustworthy tokens for the entry, or `null`. |
39
+ | `measured_subset_tokens` | Optional trustworthy measured subtotal for a known subset of the run. Omission is normalized to `null` so callers written before this field remain source-compatible. |
39
40
  | `cost` | Observed or estimated cost for this entry, or `null`. |
40
41
  | `currency` | ISO currency code when `cost` is known, otherwise `null`. |
41
42
  | `pricing_status` | `observed`, `estimated`, `missing`, or `unavailable`. |
@@ -51,13 +52,17 @@ Each direct usage entry records one logical Lisa run or sub-run on one artifact.
51
52
 
52
53
  - `observed`: the runtime supplied the usage directly. Do not replace observed counts with estimates.
53
54
  - `estimated`: Lisa derived counts or cost from trustworthy runtime metadata plus an explicit pricing contract. Estimates are allowed only when the derivation inputs are real and attributable to the run.
55
+ - `measured-subset`: Lisa measured a known subset of the run, but not enough to claim a complete `total_tokens` value. Preserve the subtotal in `measured_subset_tokens`, keep `total_tokens = null`, and keep rollup totals unknown instead of treating the subset as the whole run.
54
56
  - `unavailable`: Lisa could not obtain trustworthy usage data. Write the entry anyway with `null` token/cost fields rather than silently omitting the row.
55
57
 
56
58
  The absence of data is never treated as zero. `null` means unknown; `0` means explicitly observed or derived zero.
57
59
 
58
60
  For example, an unavailable Verify run still records a direct entry with `source = unavailable`,
59
61
  `pricing_status = unavailable`, and `null` token/cost fields so downstream readers can distinguish
60
- "missing telemetry" from "zero usage."
62
+ "missing telemetry" from "zero usage." A Plan run with measured sub-agent usage but unmeasured
63
+ main-loop usage records `source = measured-subset`, `measured_subset_tokens = <subtotal>`, and
64
+ `total_tokens = null` so the subtotal is durable without being misrepresented as the complete run
65
+ total.
61
66
 
62
67
  ## Pricing semantics
63
68
 
@@ -69,16 +74,34 @@ For example, an unavailable Verify run still records a direct entry with `source
69
74
  - `unavailable`: the runtime exposed neither trustworthy cost nor enough trustworthy token data to estimate cost.
70
75
 
71
76
  Runtime-observed cost always wins over estimates. Estimated cost never overwrites an observed value. Missing pricing preserves token counts and a `null` cost.
77
+ Token completeness and cost trust are independent: a `measured-subset` entry may still carry an
78
+ observed trustworthy whole-run cost. Token rollups remain unknown, but that cost participates in
79
+ cost rollups under the normal pricing and currency rules.
72
80
 
73
81
  ## Machine-readable tokens
74
82
 
75
- Every visible direct entry row ends with exactly one machine-readable token:
83
+ Every visible direct entry row contains the backward-compatible 17-field primary token:
76
84
 
77
85
  ```text
78
86
  <!-- lisa:usage-entry entry_id=<id> flow=<flow> run_id=<run-id> provider=<provider> model=<model> source=<source> input_tokens=<n|null> cached_input_tokens=<n|null> output_tokens=<n|null> reasoning_tokens=<n|null> total_tokens=<n|null> cost=<decimal|null> currency=<code|null> pricing_status=<status> pricing_source=<ref|null> artifact_ref=<ref> parent_artifact_ref=<ref-or-empty> -->
79
87
  ```
80
88
 
81
- Field order is fixed. A reader parses the usage ledger by matching `<!-- lisa:usage-entry ` lines only; it never needs to scrape prose or table cell positions. String fields are percent-encoded before rendering and decoded after parsing, so whitespace, commas, and HTML comment terminators inside source values cannot split or truncate the token.
89
+ The row immediately follows it with a correlated measured-subset extension. Writers serialize an
90
+ omitted value as `null` instead of `undefined`:
91
+
92
+ ```text
93
+ <!-- lisa:usage-entry-measured-subset entry_id=<id> measured_subset_tokens=<n|null> -->
94
+ ```
95
+
96
+ The primary field order is fixed and deliberately matches the pre-measured-subset contract so
97
+ legacy 17-field readers continue to enumerate entries. Current readers correlate the extension by
98
+ its percent-encoded `entry_id`. They also accept the `@codyswann/lisa@2.222.0` transitional marker,
99
+ which placed `measured_subset_tokens` between `total_tokens` and `cost`, and migrate it to the
100
+ primary-plus-extension layout on rewrite. Only that transitional additive field accepts the literal
101
+ `undefined` emitted by an older caller and normalizes it to `null`; established numeric fields
102
+ remain strict. String fields are percent-encoded before rendering and decoded after parsing, so
103
+ whitespace, commas, and HTML comment terminators inside source values cannot split or truncate the
104
+ token.
82
105
 
83
106
  Every managed section also ends with exactly one rollup token:
84
107
 
@@ -91,6 +114,23 @@ Every managed section also ends with exactly one rollup token:
91
114
  - `child_refs` enumerates the child artifacts consulted for the rollup.
92
115
  - `total_*` fields equal direct plus child totals over the deduped entry set.
93
116
 
117
+ If a direct entry or freshly resolved child entry is `measured-subset`, the corresponding token
118
+ scope and combined `total_tokens` are `null`; a measured subtotal is never added to complete token
119
+ counts. Other established nullable-entry behavior is unchanged. Cost rollups are computed
120
+ independently, so a trustworthy whole-run cost is not discarded merely because token completeness
121
+ is unknown.
122
+
123
+ When freshly resolved child work contains a measured subset, the primary rollup token is followed
124
+ by this optional backward-compatible extension:
125
+
126
+ ```text
127
+ <!-- lisa:usage-rollup-token-status child_tokens_incomplete=true -->
128
+ ```
129
+
130
+ The extension preserves child-token incompleteness across ordinary direct-entry rewrites that do
131
+ not resolve children again. It is omitted when child token totals are not known to be incomplete,
132
+ so legacy rollup objects and readers retain their established shape.
133
+
94
134
  The rollup token is the machine-readable summary. The visible rollup table mirrors it for humans. List fields are comma-delimited after encoding each item independently; commas inside an item are encoded as data, not treated as separators.
95
135
 
96
136
  ## Visible rendering contract
@@ -143,7 +183,9 @@ The rollup contract is additive across the hierarchy: PRDs may roll up Epics/Sto
143
183
  - Recompute the entire section on every write; never append ad hoc rows.
144
184
  - Sort direct entries deterministically by `(flow, run_id, entry_id)`.
145
185
  - Preserve existing entries with unchanged `entry_id` and refreshed field values.
146
- - Re-running with the same logical entry set must produce byte-identical output.
186
+ - Re-running with the same logical entry set must produce byte-identical output. Rewriting a legacy
187
+ primary-only marker or the 2.222.0 transitional marker migrates once to the canonical
188
+ primary-plus-extension layout; subsequent rewrites are byte-identical.
147
189
  - Do not include timestamps in the section preamble or token lines.
148
190
 
149
191
  Idempotency is enforced by `entry_id` for direct entries and by the fixed rollup token field order for totals.
@@ -21,7 +21,8 @@ Every artifact with inline body content gets exactly one section:
21
21
 
22
22
  Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is the stable dedupe key — rewriting the same logical run with the same `entry_id` updates in place; a different run gets a different `entry_id`.
23
23
 
24
- - **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `unavailable`.
24
+ - **`source`**: `observed` (runtime supplied) / `estimated` (derived from trustworthy metadata + pricing contract) / `measured-subset` (a trustworthy subtotal exists, but the complete run total is unknown) / `unavailable`.
25
+ - **`measured_subset_tokens`**: optional measured subtotal for `measured-subset` entries only. Omission is normalized to `null` for backward-compatible callers. Keep `total_tokens = null` so rollups do not treat a subset as a complete total.
25
26
  - **`pricing_status`**: same trinary plus `missing` (cost not known but should be).
26
27
  - **Absence ≠ zero.** `null` means unknown; `0` means explicitly zero. Always write the entry — never silently omit.
27
28
  - Do NOT replace observed counts with estimates.
@@ -30,4 +31,8 @@ Each direct entry records ONE logical Lisa run on ONE artifact. `entry_id` is th
30
31
 
31
32
  Container artifacts (Epic, PRD, etc.) roll up usage from their direct children. Roll-up is recursive — a parent's `## Lisa Usage` aggregates its descendants' direct entries. Re-writes are idempotent: re-running an intake or lifecycle skill must not duplicate entries.
32
33
 
33
- Full schema (all 17 fields, pricing semantics, rollup math, idempotent-rewrite rules): [reference/usage-accounting.md](usage-accounting-reference.mdc).
34
+ Measured-child incompleteness is durable across ordinary rewrites through the optional
35
+ `lisa:usage-rollup-token-status` extension. Do not infer completeness merely because a rewrite did
36
+ not re-fetch child ledgers.
37
+
38
+ Full schema (backward-compatible 17-field primary marker, correlated measured-subset extension, pricing semantics, rollup math, idempotent-migration rules): [reference/usage-accounting.md](usage-accounting-reference.mdc).
@@ -67,6 +67,13 @@ and artifact refs. Callers do not get to omit the "unavailable" case; when trust
67
67
  missing they still pass an explicit entry with `source: unavailable` and nullable token/cost
68
68
  fields.
69
69
 
70
+ When the runtime exposes only a trustworthy subtotal, callers MUST use `source: measured-subset`,
71
+ write the subtotal to `measured_subset_tokens`, and leave `total_tokens: null`. Do not coerce a
72
+ known subset into `total_tokens`; rollups use `total_tokens` only for complete totals. The
73
+ `measured_subset_tokens` field is optional for backward compatibility with callers that construct
74
+ ordinary observed, estimated, or unavailable entries; the shared serializer normalizes omission
75
+ to `null`. A trustworthy whole-run cost remains valid independently of incomplete token telemetry.
76
+
70
77
  ## Return shape
71
78
 
72
79
  Return structured output so callers can persist or log what happened without reparsing prose:
@@ -164,6 +171,11 @@ failures into a generic "usage update failed."
164
171
  canonical `usage-accounting` rule.
165
172
  - Never append a second `## Lisa Usage` section or a second managed usage comment.
166
173
  - Never treat missing usage as zero. Callers must record explicit `source: unavailable` entries.
174
+ - Never add a measured subset to complete token totals. A mixed complete-plus-measured-subset
175
+ direct or child scope has `null` token rollups, while trustworthy whole-run cost rolls up
176
+ independently.
177
+ - Never discard the optional child-token incompleteness state parsed from an existing rollup when
178
+ `child_refs` were not refreshed. Preserve it through ordinary direct-entry rewrites.
167
179
  - Never skip rollup dedupe. Child totals are keyed by stable `entry_id`, not by child ref count.
168
180
  - Never silently drop to comments. Return `outcome: comment-fallback` so the caller can surface the
169
181
  writable surface that actually holds the ledger.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Expo and React Native-specific skills, agents, rules, and MCP servers.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Harper/Fabric-specific Lisa rules for TypeScript component apps.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "NestJS-specific skills and migration write-protection hooks.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (migration write-protection)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "2.221.6",
3
+ "version": "2.222.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"