@codyswann/lisa 4.19.0 → 4.21.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.
Files changed (133) hide show
  1. package/all/copy-contents/.gitattributes +2 -1
  2. package/all/create-only/.lisa/PROJECT_LEARNINGS.md +1 -1
  3. package/dist/core/learnings-alias.d.ts +26 -45
  4. package/dist/core/learnings-alias.d.ts.map +1 -1
  5. package/dist/core/learnings-alias.js +29 -48
  6. package/dist/core/learnings-alias.js.map +1 -1
  7. package/dist/core/learnings-budget-check.d.ts +2 -1
  8. package/dist/core/learnings-budget-check.d.ts.map +1 -1
  9. package/dist/core/learnings-budget-check.js +13 -11
  10. package/dist/core/learnings-budget-check.js.map +1 -1
  11. package/dist/core/learnings-contract.d.ts +27 -10
  12. package/dist/core/learnings-contract.d.ts.map +1 -1
  13. package/dist/core/learnings-contract.js +37 -9
  14. package/dist/core/learnings-contract.js.map +1 -1
  15. package/dist/core/learnings-document.d.ts +20 -1
  16. package/dist/core/learnings-document.d.ts.map +1 -1
  17. package/dist/core/learnings-document.js +81 -14
  18. package/dist/core/learnings-document.js.map +1 -1
  19. package/dist/core/learnings-entry.d.ts +11 -1
  20. package/dist/core/learnings-entry.d.ts.map +1 -1
  21. package/dist/core/learnings-entry.js +98 -24
  22. package/dist/core/learnings-entry.js.map +1 -1
  23. package/dist/core/learnings-merge-driver.d.ts +4 -2
  24. package/dist/core/learnings-merge-driver.d.ts.map +1 -1
  25. package/dist/core/learnings-merge-driver.js +6 -3
  26. package/dist/core/learnings-merge-driver.js.map +1 -1
  27. package/dist/core/learnings-merge.d.ts.map +1 -1
  28. package/dist/core/learnings-merge.js +96 -10
  29. package/dist/core/learnings-merge.js.map +1 -1
  30. package/dist/core/learnings-overflow.d.ts.map +1 -1
  31. package/dist/core/learnings-overflow.js +72 -3
  32. package/dist/core/learnings-overflow.js.map +1 -1
  33. package/dist/core/learnings-supersede.d.ts +56 -0
  34. package/dist/core/learnings-supersede.d.ts.map +1 -0
  35. package/dist/core/learnings-supersede.js +199 -0
  36. package/dist/core/learnings-supersede.js.map +1 -0
  37. package/dist/core/learnings-writer.d.ts +9 -7
  38. package/dist/core/learnings-writer.d.ts.map +1 -1
  39. package/dist/core/learnings-writer.js +31 -58
  40. package/dist/core/learnings-writer.js.map +1 -1
  41. package/dist/core/learnings.d.ts +3 -0
  42. package/dist/core/learnings.d.ts.map +1 -1
  43. package/dist/core/learnings.js +3 -0
  44. package/dist/core/learnings.js.map +1 -1
  45. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  46. package/dist/core/upstream-evidence-manifest.js +24 -7
  47. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  48. package/package.json +3 -2
  49. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  51. package/plugins/lisa/.codex-plugin/skills/lisa-debrief-apply/SKILL.md +5 -4
  52. package/plugins/lisa/.codex-plugin/skills/lisa-persist-learning/SKILL.md +2 -2
  53. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  54. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  55. package/plugins/lisa/agents/learner.md +7 -6
  56. package/plugins/lisa/rules/reference/project-learnings.md +34 -1
  57. package/plugins/lisa/skills/lisa-debrief-apply/SKILL.md +5 -4
  58. package/plugins/lisa/skills/lisa-persist-learning/SKILL.md +2 -2
  59. package/plugins/lisa/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  60. package/plugins/lisa/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  61. package/plugins/lisa-agy/agents/learner.md +7 -6
  62. package/plugins/lisa-agy/plugin.json +1 -1
  63. package/plugins/lisa-agy/skills/lisa-debrief-apply/SKILL.md +5 -4
  64. package/plugins/lisa-agy/skills/lisa-persist-learning/SKILL.md +2 -2
  65. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  66. package/plugins/lisa-agy/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  67. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  69. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  70. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-copilot/agents/learner.agent.md +7 -6
  74. package/plugins/lisa-copilot/rules/reference/project-learnings.md +34 -1
  75. package/plugins/lisa-copilot/skills/lisa-debrief-apply/SKILL.md +5 -4
  76. package/plugins/lisa-copilot/skills/lisa-persist-learning/SKILL.md +2 -2
  77. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  78. package/plugins/lisa-copilot/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  79. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-cursor/agents/learner.md +7 -6
  81. package/plugins/lisa-cursor/rules/project-learnings-reference.mdc +34 -1
  82. package/plugins/lisa-cursor/skills/lisa-debrief-apply/SKILL.md +5 -4
  83. package/plugins/lisa-cursor/skills/lisa-persist-learning/SKILL.md +2 -2
  84. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  85. package/plugins/lisa-cursor/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  86. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-expo-agy/plugin.json +1 -1
  89. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  92. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  93. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  94. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  95. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  97. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  98. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  99. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  100. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  102. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  103. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  104. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  106. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  107. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  108. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  109. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  111. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  113. package/plugins/lisa-rails-agy/plugin.json +1 -1
  114. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  116. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  118. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  119. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  120. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  121. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  123. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  124. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  125. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  126. package/plugins/src/base/agents/learner.md +7 -6
  127. package/plugins/src/base/rules/reference/project-learnings.md +34 -1
  128. package/plugins/src/base/skills/lisa-debrief-apply/SKILL.md +5 -4
  129. package/plugins/src/base/skills/lisa-persist-learning/SKILL.md +2 -2
  130. package/plugins/src/base/skills/lisa-secrets-access/scripts/publish-aws-bootstrap.mjs +349 -0
  131. package/plugins/src/base/skills/lisa-setup-remote-aws/SKILL.md +23 -5
  132. package/scripts/verify-learner-frontmatter-built.mjs +1 -1
  133. package/scripts/verify-packed-learnings-contract.mjs +268 -0
@@ -2,7 +2,8 @@
2
2
 
3
3
  # The project learnings ledger is written by concurrent learner passes that
4
4
  # each run on their own branch. Git's default line merge corrupts it with
5
- # conflict markers; this driver unions entries by id instead. The driver
5
+ # conflict markers; this driver merges entries by id and fingerprint. The
6
+ # driver preserves concurrent stable-id successors instead of guessing. Its
6
7
  # command is machine-local — run `lisa install-merge-driver` to register it.
7
8
  # `lisa doctor` already reports this as "Merge drivers registered?" when a
8
9
  # mapping here has no registered driver — named at the symptom site on
@@ -1,6 +1,6 @@
1
1
  # Project Learnings
2
2
 
3
- <!-- lisa-learnings-contract:v1 -->
3
+ <!-- lisa-learnings-contract:v2 -->
4
4
 
5
5
  ```jsonl
6
6
 
@@ -1,53 +1,36 @@
1
1
  /**
2
- * Reference survival across supersede-in-place consolidation.
2
+ * Reference survival across stamped supersede-in-place consolidation.
3
3
  *
4
4
  * ## The problem
5
5
  *
6
- * `persistConsolidatedLearning(..., { supersede: [ids] })` removes the
7
- * superseded entries and adds a new one under the caller's own id — the
8
- * learner's content fingerprint. So every consolidation churns the id, and
9
- * anything that had cited the old id (a tracker comment, a gardener ticket, a
10
- * cross-link from another learning) silently points at an entry that no longer
11
- * exists (CodySwannGT/lisa#1997).
6
+ * Learning ids are stable public references, while fingerprints are immutable
7
+ * content-version tokens. An exact stamped consolidation keeps the
8
+ * deterministic primary target id, but a multi-target consolidation removes
9
+ * the other live ids. Anything that cited one of those secondary ids (a
10
+ * tracker comment, a gardener ticket, or a cross-link from another learning)
11
+ * would otherwise point at an entry that no longer exists
12
+ * (CodySwannGT/lisa#1997).
12
13
  *
13
- * ## Why an alias map and NOT "carry the earliest superseded id forward"
14
+ * ## Why aliases still matter after stable-id carry-forward
14
15
  *
15
- * The issue offered both. Carry-forward was implemented first and had to be
16
- * abandoned, because the churning fingerprint id is doing a second job nobody
17
- * wrote down: it is an accidental **compare-and-swap token**.
16
+ * The persisted v2 fingerprint is the compare-and-swap token that makes stable
17
+ * ids safe. Two learner passes racing from the same `{ id, fingerprint }`
18
+ * snapshot cannot overwrite one another: the first exact writer carries the id
19
+ * forward, the second sees a fingerprint mismatch and appends without removing
20
+ * the winner (#1995). A legitimate chained writer holding the winner's current
21
+ * fingerprint can replace it in place.
18
22
  *
19
- * Two learner passes racing to consolidate the same entry `base` each hold a
20
- * stale snapshot. Today the first writer removes `base` and lands under `a`; the
21
- * second finds `base` already gone, is tolerated rather than fatal (#1995), and
22
- * lands under `b`. Both learnings survive — "at worst two entries where one
23
- * consolidation was intended," exactly the cost the writer documents.
24
- *
25
- * Carry the id forward and that protection evaporates: the first writer lands
26
- * under `base`, so the second writer's stale "supersede base" now MATCHES,
27
- * removes the first writer's entry, and overwrites it. `learnings-supersede-race`
28
- * proves the damage — nine writers consolidating one target went from nine
29
- * preserved learnings to **one**, destroying eight. That is the #1995 data-loss
30
- * symptom re-opened, which the brief explicitly forbids.
31
- *
32
- * The fix is undecidable from the seven fields alone: a stale "supersede base"
33
- * and a legitimate chained "supersede base" are the same bytes. Telling them
34
- * apart needs a real version token — the fingerprint retained as an eighth,
35
- * disambiguating field, per the issue's parenthetical. That is a persisted-schema
36
- * change: a contract version bump propagated through every reader, the merge
37
- * driver, the CI budget gate, and all six plugin skill projections. It is the
38
- * principled long-term answer and it deserves its own change.
39
- *
40
- * So this takes the issue's second option. Ids keep churning — the CAS token,
41
- * the #1995 guarantee, and the fingerprint-is-the-id dedupe model are all left
42
- * exactly as they are — and references survive because the consolidated entry
43
- * *records what it replaced*.
23
+ * Stable carry-forward preserves the deterministic primary id. Aliases preserve
24
+ * every other exact target and inherited ancestor in a multi-entry
25
+ * consolidation. They are therefore a reference-history layer, never a stale
26
+ * write workaround and never a substitute for stamped compare-and-swap.
44
27
  *
45
28
  * ## Where the map lives
46
29
  *
47
- * In the entry's own `provenance`, as `supersedes:<old id>` references. No new
48
- * field, no new file, no new format: provenance is already a validated,
49
- * rendered, merged, budget-counted list of stable references, and "this entry
50
- * replaced that one" is precisely a provenance claim.
30
+ * In the entry's own `provenance`, as `supersedes:<old id>` references. No
31
+ * additional schema field or sidecar is required: provenance is already a
32
+ * validated, rendered, merged, budget-counted list of stable references, and
33
+ * "this entry replaced that one" is precisely a provenance claim.
51
34
  *
52
35
  * Resolution is ONE HOP, never transitive. When an entry is consolidated, the
53
36
  * writer copies the removed entries' own alias references forward, so a lineage
@@ -55,11 +38,9 @@
55
38
  * There is no chain for a reader to walk and therefore no cycle or depth limit
56
39
  * to get wrong.
57
40
  *
58
- * An alias is recorded ONLY for a target that was actually present and removed.
59
- * A supersede naming an already-consolidated id removed nothing, so claiming its
60
- * reference would hijack a pointer that the earlier writer legitimately owns —
61
- * in the nine-writer race, only the one writer that truly removed `base` claims
62
- * `base`, and the reference stays unambiguous.
41
+ * An alias is recorded ONLY for a target whose exact stamp was present and
42
+ * removed. A stale all-or-nothing plan removes nothing and records no alias, so
43
+ * it cannot hijack a reference that the winning writer legitimately owns.
63
44
  * @module core/learnings-alias
64
45
  */
65
46
  import { type LearningEntry } from "./learnings-contract.js";
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-alias.d.ts","sourceRoot":"","sources":["../../src/core/learnings-alias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,aAAa,GACnB,KAAK,GAAG,SAAS,CASnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAKzE;AA4BD,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,oBAAoB,CActB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,EAAE,EAAE,MAAM,GACT,SAAS,aAAa,EAAE,CAS1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,EAAE,EAAE,MAAM,GACT,aAAa,GAAG,SAAS,CAE3B"}
1
+ {"version":3,"file":"learnings-alias.d.ts","sourceRoot":"","sources":["../../src/core/learnings-alias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,aAAa,GACnB,KAAK,GAAG,SAAS,CASnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAKzE;AA4BD,oEAAoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,oBAAoB,CActB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,EAAE,EAAE,MAAM,GACT,SAAS,aAAa,EAAE,CAS1B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,EAAE,EAAE,MAAM,GACT,aAAa,GAAG,SAAS,CAE3B"}
@@ -1,53 +1,36 @@
1
1
  /**
2
- * Reference survival across supersede-in-place consolidation.
2
+ * Reference survival across stamped supersede-in-place consolidation.
3
3
  *
4
4
  * ## The problem
5
5
  *
6
- * `persistConsolidatedLearning(..., { supersede: [ids] })` removes the
7
- * superseded entries and adds a new one under the caller's own id — the
8
- * learner's content fingerprint. So every consolidation churns the id, and
9
- * anything that had cited the old id (a tracker comment, a gardener ticket, a
10
- * cross-link from another learning) silently points at an entry that no longer
11
- * exists (CodySwannGT/lisa#1997).
12
- *
13
- * ## Why an alias map and NOT "carry the earliest superseded id forward"
14
- *
15
- * The issue offered both. Carry-forward was implemented first and had to be
16
- * abandoned, because the churning fingerprint id is doing a second job nobody
17
- * wrote down: it is an accidental **compare-and-swap token**.
18
- *
19
- * Two learner passes racing to consolidate the same entry `base` each hold a
20
- * stale snapshot. Today the first writer removes `base` and lands under `a`; the
21
- * second finds `base` already gone, is tolerated rather than fatal (#1995), and
22
- * lands under `b`. Both learnings survive — "at worst two entries where one
23
- * consolidation was intended," exactly the cost the writer documents.
24
- *
25
- * Carry the id forward and that protection evaporates: the first writer lands
26
- * under `base`, so the second writer's stale "supersede base" now MATCHES,
27
- * removes the first writer's entry, and overwrites it. `learnings-supersede-race`
28
- * proves the damage — nine writers consolidating one target went from nine
29
- * preserved learnings to **one**, destroying eight. That is the #1995 data-loss
30
- * symptom re-opened, which the brief explicitly forbids.
31
- *
32
- * The fix is undecidable from the seven fields alone: a stale "supersede base"
33
- * and a legitimate chained "supersede base" are the same bytes. Telling them
34
- * apart needs a real version token — the fingerprint retained as an eighth,
35
- * disambiguating field, per the issue's parenthetical. That is a persisted-schema
36
- * change: a contract version bump propagated through every reader, the merge
37
- * driver, the CI budget gate, and all six plugin skill projections. It is the
38
- * principled long-term answer and it deserves its own change.
39
- *
40
- * So this takes the issue's second option. Ids keep churning — the CAS token,
41
- * the #1995 guarantee, and the fingerprint-is-the-id dedupe model are all left
42
- * exactly as they are — and references survive because the consolidated entry
43
- * *records what it replaced*.
6
+ * Learning ids are stable public references, while fingerprints are immutable
7
+ * content-version tokens. An exact stamped consolidation keeps the
8
+ * deterministic primary target id, but a multi-target consolidation removes
9
+ * the other live ids. Anything that cited one of those secondary ids (a
10
+ * tracker comment, a gardener ticket, or a cross-link from another learning)
11
+ * would otherwise point at an entry that no longer exists
12
+ * (CodySwannGT/lisa#1997).
13
+ *
14
+ * ## Why aliases still matter after stable-id carry-forward
15
+ *
16
+ * The persisted v2 fingerprint is the compare-and-swap token that makes stable
17
+ * ids safe. Two learner passes racing from the same `{ id, fingerprint }`
18
+ * snapshot cannot overwrite one another: the first exact writer carries the id
19
+ * forward, the second sees a fingerprint mismatch and appends without removing
20
+ * the winner (#1995). A legitimate chained writer holding the winner's current
21
+ * fingerprint can replace it in place.
22
+ *
23
+ * Stable carry-forward preserves the deterministic primary id. Aliases preserve
24
+ * every other exact target and inherited ancestor in a multi-entry
25
+ * consolidation. They are therefore a reference-history layer, never a stale
26
+ * write workaround and never a substitute for stamped compare-and-swap.
44
27
  *
45
28
  * ## Where the map lives
46
29
  *
47
- * In the entry's own `provenance`, as `supersedes:<old id>` references. No new
48
- * field, no new file, no new format: provenance is already a validated,
49
- * rendered, merged, budget-counted list of stable references, and "this entry
50
- * replaced that one" is precisely a provenance claim.
30
+ * In the entry's own `provenance`, as `supersedes:<old id>` references. No
31
+ * additional schema field or sidecar is required: provenance is already a
32
+ * validated, rendered, merged, budget-counted list of stable references, and
33
+ * "this entry replaced that one" is precisely a provenance claim.
51
34
  *
52
35
  * Resolution is ONE HOP, never transitive. When an entry is consolidated, the
53
36
  * writer copies the removed entries' own alias references forward, so a lineage
@@ -55,11 +38,9 @@
55
38
  * There is no chain for a reader to walk and therefore no cycle or depth limit
56
39
  * to get wrong.
57
40
  *
58
- * An alias is recorded ONLY for a target that was actually present and removed.
59
- * A supersede naming an already-consolidated id removed nothing, so claiming its
60
- * reference would hijack a pointer that the earlier writer legitimately owns —
61
- * in the nine-writer race, only the one writer that truly removed `base` claims
62
- * `base`, and the reference stays unambiguous.
41
+ * An alias is recorded ONLY for a target whose exact stamp was present and
42
+ * removed. A stale all-or-nothing plan removes nothing and records no alias, so
43
+ * it cannot hijack a reference that the winning writer legitimately owns.
63
44
  * @module core/learnings-alias
64
45
  */
65
46
  import { LEARNINGS_CONTRACT, } from "./learnings-contract.js";
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-alias.js","sourceRoot":"","sources":["../../src/core/learnings-alias.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,OAAO,EACL,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAEjC,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,OAAO,GAAG,iBAAiB,GAAG,EAAE,EAAE,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAoB;IAEpB,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CACjD,SAAS,CAAC,UAAU,CAAC,iBAAiB,CAAC,CACxC,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;QACxB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAI,KAAK,CACP,wBAAwB,iBAAiB,+DAA+D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7H,CAAC;AACR,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAoB;IACpD,OAAO,KAAK,CAAC,UAAU;SACpB,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;SAC5D,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;SAC3D,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAiC,EACjC,EAAU;IAEV,OAAO,yBAAyB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
@@ -95,9 +95,10 @@ export declare function checkLearningsBudget(file: string): Promise<LearningsBud
95
95
  * failed. This verdict is the same fact, said before anyone pays for it.
96
96
  * @param entryCount - Entries the document holds
97
97
  * @param measuredTokens - Measured document size under the contract's measure
98
+ * @param maxTokens - Source-version byte ceiling used for saturation
98
99
  * @returns Single-line saturation clause, or undefined when room remains
99
100
  */
100
- export declare function describeLearningsSaturation(entryCount: number, measuredTokens: number): string | undefined;
101
+ export declare function describeLearningsSaturation(entryCount: number, measuredTokens: number, maxTokens?: number): string | undefined;
101
102
  /**
102
103
  * Render the one operator-facing verdict line for a within-budget document.
103
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-budget-check.d.ts","sourceRoot":"","sources":["../../src/core/learnings-budget-check.ts"],"names":[],"mappings":"AAgCA,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8EAA8E;AAC9E,MAAM,WAAW,wBAAwB;IACvC,QAA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AI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8EAA8E;AAC9E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8CAA8C;AAC9C,MAAM,MAAM,qBAAqB,GAC7B,iBAAiB,GACjB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,CAiChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,GAAE,MAAqC,GAC/C,MAAM,GAAG,SAAS,CAcpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GACxB,MAAM,CAKR;AAiDD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYxD;AAoCD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -17,7 +17,7 @@
17
17
  import { constants } from "node:fs";
18
18
  import { open } from "node:fs/promises";
19
19
  import { LEARNINGS_CONTRACT, PER_ENTRY_BYTE_ALLOWANCE, estimateLearningTokens, } from "./learnings-contract.js";
20
- import { CONFLICT_MARKER_DIAGNOSIS, conflictMarkerError, findConflictMarkerInBytes, parseLearningsFile, renderLearningsFile, } from "./learnings-document.js";
20
+ import { CONFLICT_MARKER_DIAGNOSIS, conflictMarkerError, findConflictMarkerInBytes, parseLearningsDocument, } from "./learnings-document.js";
21
21
  import { validateLearningEntry } from "./learnings-entry.js";
22
22
  /**
23
23
  * Check one already-resolved absolute learnings path against the shared hard
@@ -30,14 +30,12 @@ export async function checkLearningsBudget(file) {
30
30
  try {
31
31
  const content = await readBoundedRegularFile(file, LEARNINGS_CONTRACT.maxTokens);
32
32
  const measuredTokens = estimateLearningTokens(content);
33
- if (measuredTokens > LEARNINGS_CONTRACT.maxTokens) {
34
- throw new Error(`maxTokens exceeded: measured ${measuredTokens}, allowed ${LEARNINGS_CONTRACT.maxTokens}`);
35
- }
36
- const entries = parseLearningsFile(content);
33
+ const document = parseLearningsDocument(content);
34
+ const entries = document.entries;
37
35
  for (const entry of entries) {
38
36
  validateLearningEntry(entry);
39
37
  }
40
- if (renderLearningsFile(entries) !== content) {
38
+ if (!document.canonicalSource) {
41
39
  throw new Error("non-canonical project learnings format");
42
40
  }
43
41
  return {
@@ -45,8 +43,8 @@ export async function checkLearningsBudget(file) {
45
43
  entryCount: entries.length,
46
44
  maxEntries: LEARNINGS_CONTRACT.maxEntries,
47
45
  measuredTokens,
48
- maxTokens: LEARNINGS_CONTRACT.maxTokens,
49
- saturation: describeLearningsSaturation(entries.length, measuredTokens),
46
+ maxTokens: document.sourceMaxTokens,
47
+ saturation: describeLearningsSaturation(entries.length, measuredTokens, document.sourceMaxTokens),
50
48
  };
51
49
  }
52
50
  catch (error) {
@@ -112,17 +110,21 @@ export async function checkLearningsBudget(file) {
112
110
  * failed. This verdict is the same fact, said before anyone pays for it.
113
111
  * @param entryCount - Entries the document holds
114
112
  * @param measuredTokens - Measured document size under the contract's measure
113
+ * @param maxTokens - Source-version byte ceiling used for saturation
115
114
  * @returns Single-line saturation clause, or undefined when room remains
116
115
  */
117
- export function describeLearningsSaturation(entryCount, measuredTokens) {
116
+ export function describeLearningsSaturation(entryCount, measuredTokens, maxTokens = LEARNINGS_CONTRACT.maxTokens) {
117
+ const averageEntryAllowance = maxTokens === LEARNINGS_CONTRACT.maxTokens
118
+ ? PER_ENTRY_BYTE_ALLOWANCE
119
+ : Math.floor(maxTokens / LEARNINGS_CONTRACT.maxEntries);
118
120
  const entriesFull = entryCount >= LEARNINGS_CONTRACT.maxEntries;
119
- const bytesFull = measuredTokens + PER_ENTRY_BYTE_ALLOWANCE > LEARNINGS_CONTRACT.maxTokens;
121
+ const bytesFull = measuredTokens + averageEntryAllowance > maxTokens;
120
122
  if (!entriesFull && !bytesFull) {
121
123
  return undefined;
122
124
  }
123
125
  const reason = entriesFull
124
126
  ? `every one of the ${LEARNINGS_CONTRACT.maxEntries} entry slots is taken`
125
- : `fewer than ${PER_ENTRY_BYTE_ALLOWANCE} bytes remain, less than one average entry`;
127
+ : `fewer than ${averageEntryAllowance} bytes remain, less than one average entry`;
126
128
  return `${reason}, so the next learning captured here will be rejected. Retire or promote an entry with the gardener (\`/lisa:learnings:audit\`); raising the cap is not the remedy`;
127
129
  }
128
130
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-budget-check.js","sourceRoot":"","sources":["../../src/core/learnings-budget-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AA0C7D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAY;IAEZ,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAC1C,IAAI,EACJ,kBAAkB,CAAC,SAAS,CAC7B,CAAC;QACF,MAAM,cAAc,GAAG,sBAAsB,CAAC,OAAO,CAA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G,KAAK,MAAM,CAAC,GAAG;YACxB,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;YAC1B,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;YAChC,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO,EAChC,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CACrD,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAC9B,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,UAAU,CACvB,MAAkB,EAClB,MAAc,EACd,MAAc;IAEd,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAC9B,MAAM,EACN,MAAM,EACN,MAAM,CAAC,MAAM,GAAG,MAAM,EACtB,IAAI,CACL,CAAC;IACF,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"learnings-budget-check.js","sourceRoot":"","sources":["../../src/core/learnings-budget-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,wBAA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AAM,EACN,MAAM,EACN,MAAM,CAAC,MAAM,GAAG,MAAM,EACtB,IAAI,CACL,CAAC;IACF,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/D,CAAC"}
@@ -7,19 +7,34 @@
7
7
  export declare const LEARNING_CONFIDENCE_VALUES: readonly ["low", "medium", "high"];
8
8
  /** Confidence vocabulary persisted in every learning entry. */
9
9
  export type LearningConfidence = (typeof LEARNING_CONFIDENCE_VALUES)[number];
10
+ /** Exact persisted fields accepted from the compatibility-window v1 schema. */
11
+ export declare const LEGACY_LEARNING_ENTRY_FIELDS: readonly ["id", "rule", "why", "provenance", "first_learned", "last_confirmed", "confidence"];
12
+ /** Historical v1 byte ceiling, retained only for source-version validation. */
13
+ export declare const LEGACY_LEARNINGS_MAX_TOKENS = 12000;
14
+ /**
15
+ * Maximum UTF-8 bytes in a persisted id or fingerprint.
16
+ *
17
+ * Stable tokens are machine keys, not prose. Bounding them keeps comparison
18
+ * and diagnostics cheap and, critically, closes the v1 compatibility window:
19
+ * v1 duplicated every id into the new fingerprint field during migration.
20
+ */
21
+ export declare const MAX_STABLE_TOKEN_BYTES = 128;
10
22
  /**
11
23
  * Average per-entry byte allowance used to DERIVE the whole-file byte budget
12
24
  * (`maxTokens = maxEntries * PER_ENTRY_BYTE_ALLOWANCE`), so the entry cap and
13
- * the byte cap can never contradict.
25
+ * the byte cap can never contradict. It is the historical v1 average plus the
26
+ * maximum bytes v2 adds when migration persists `fingerprint = id`:
27
+ * `600 + 17 + 128 = 745`. Therefore every accepted 12,000-byte v1 document
28
+ * with at most 20 bounded ids renders as v2 within 14,900 bytes.
14
29
  *
15
30
  * This is an AVERAGE budget, not a per-entry maximum: `maxTokens` is enforced
16
31
  * against the whole rendered document — every entry plus the ```jsonl framing
17
- * (~72 B observed) — and there is NO per-entry byte cap (`rule` is char-capped
18
- * at `maxRuleCharacters`; `why` is bounded only by the document total). At 600
19
- * against a ~490 B observed average, each entry carries ~110 B of headroom, so
20
- * a full 20-entry ledger budgets 12000 B while real content lands near 9800 B —
21
- * the ~2.2 KB slack absorbs the document framing many times over and leaves room
22
- * for larger-than-average entries. A single pathologically large `why` can
32
+ * (~72 B observed) — and there is no aggregate per-entry byte cap (machine
33
+ * identity tokens have their migration bound, `rule` is char-capped at
34
+ * `maxRuleCharacters`, and `why` is bounded only by the document total). The
35
+ * v2 allowance includes the persisted fingerprint while preserving meaningful
36
+ * framing and variance headroom at the full 20-entry ceiling. A single
37
+ * pathologically large `why` can
23
38
  * consume a disproportionate share; that is intended — the document total is the
24
39
  * real constraint, and the near-boundary regression test pins that behavior.
25
40
  *
@@ -28,10 +43,10 @@ export type LearningConfidence = (typeof LEARNING_CONFIDENCE_VALUES)[number];
28
43
  * valid captures far under the entry ceiling (CodySwannGT/lisa#1959). Deriving
29
44
  * the byte cap from the entry cap removes that contradiction at the source.
30
45
  */
31
- export declare const PER_ENTRY_BYTE_ALLOWANCE = 600;
46
+ export declare const PER_ENTRY_BYTE_ALLOWANCE: number;
32
47
  export declare const LEARNINGS_CONTRACT: Readonly<{
33
- readonly version: 1;
34
- readonly fields: readonly ["id", "rule", "why", "provenance", "first_learned", "last_confirmed", "confidence"];
48
+ readonly version: 2;
49
+ readonly fields: readonly ["id", "fingerprint", "rule", "why", "provenance", "first_learned", "last_confirmed", "confidence"];
35
50
  readonly maxRuleCharacters: 240;
36
51
  readonly maxRuleLines: 2;
37
52
  readonly maxProvenanceReferences: 20;
@@ -42,6 +57,8 @@ export declare const LEARNINGS_CONTRACT: Readonly<{
42
57
  /** Complete persisted schema for one project learning. */
43
58
  export interface LearningEntry {
44
59
  readonly id: string;
60
+ /** Content-version token used for exact supersede compare-and-swap. */
61
+ readonly fingerprint: string;
45
62
  readonly rule: string;
46
63
  readonly why: string;
47
64
  readonly provenance: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-contract.d.ts","sourceRoot":"","sources":["../../src/core/learnings-contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,0BAA0B,oCAAqC,CAAC;AAE7E,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAK7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,kBAAkB;;;;;;;;;EAiBpB,CAAC;AAEZ,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D"}
1
+ {"version":3,"file":"learnings-contract.d.ts","sourceRoot":"","sources":["../../src/core/learnings-contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,0BAA0B,oCAAqC,CAAC;AAE7E,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAK7E,+EAA+E;AAC/E,eAAO,MAAM,4BAA4B,+FAQ9B,CAAC;AAEZ,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAK1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,QAGb,CAAC;AAEzB,eAAO,MAAM,kBAAkB;;;;;;;;;EAkBpB,CAAC;AAEZ,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D"}
@@ -7,19 +7,44 @@
7
7
  export const LEARNING_CONFIDENCE_VALUES = ["low", "medium", "high"];
8
8
  /** Maximum number of durable entries the ledger retains. */
9
9
  const MAX_ENTRIES = 20;
10
+ /** Exact persisted fields accepted from the compatibility-window v1 schema. */
11
+ export const LEGACY_LEARNING_ENTRY_FIELDS = Object.freeze([
12
+ "id",
13
+ "rule",
14
+ "why",
15
+ "provenance",
16
+ "first_learned",
17
+ "last_confirmed",
18
+ "confidence",
19
+ ]);
20
+ /** Historical v1 byte ceiling, retained only for source-version validation. */
21
+ export const LEGACY_LEARNINGS_MAX_TOKENS = 12_000;
22
+ /**
23
+ * Maximum UTF-8 bytes in a persisted id or fingerprint.
24
+ *
25
+ * Stable tokens are machine keys, not prose. Bounding them keeps comparison
26
+ * and diagnostics cheap and, critically, closes the v1 compatibility window:
27
+ * v1 duplicated every id into the new fingerprint field during migration.
28
+ */
29
+ export const MAX_STABLE_TOKEN_BYTES = 128;
30
+ /** JSON bytes v2 adds around each migrated v1 id: `,"fingerprint":""`. */
31
+ const FINGERPRINT_FIELD_BYTE_OVERHEAD = 17;
10
32
  /**
11
33
  * Average per-entry byte allowance used to DERIVE the whole-file byte budget
12
34
  * (`maxTokens = maxEntries * PER_ENTRY_BYTE_ALLOWANCE`), so the entry cap and
13
- * the byte cap can never contradict.
35
+ * the byte cap can never contradict. It is the historical v1 average plus the
36
+ * maximum bytes v2 adds when migration persists `fingerprint = id`:
37
+ * `600 + 17 + 128 = 745`. Therefore every accepted 12,000-byte v1 document
38
+ * with at most 20 bounded ids renders as v2 within 14,900 bytes.
14
39
  *
15
40
  * This is an AVERAGE budget, not a per-entry maximum: `maxTokens` is enforced
16
41
  * against the whole rendered document — every entry plus the ```jsonl framing
17
- * (~72 B observed) — and there is NO per-entry byte cap (`rule` is char-capped
18
- * at `maxRuleCharacters`; `why` is bounded only by the document total). At 600
19
- * against a ~490 B observed average, each entry carries ~110 B of headroom, so
20
- * a full 20-entry ledger budgets 12000 B while real content lands near 9800 B —
21
- * the ~2.2 KB slack absorbs the document framing many times over and leaves room
22
- * for larger-than-average entries. A single pathologically large `why` can
42
+ * (~72 B observed) — and there is no aggregate per-entry byte cap (machine
43
+ * identity tokens have their migration bound, `rule` is char-capped at
44
+ * `maxRuleCharacters`, and `why` is bounded only by the document total). The
45
+ * v2 allowance includes the persisted fingerprint while preserving meaningful
46
+ * framing and variance headroom at the full 20-entry ceiling. A single
47
+ * pathologically large `why` can
23
48
  * consume a disproportionate share; that is intended — the document total is the
24
49
  * real constraint, and the near-boundary regression test pins that behavior.
25
50
  *
@@ -28,11 +53,14 @@ const MAX_ENTRIES = 20;
28
53
  * valid captures far under the entry ceiling (CodySwannGT/lisa#1959). Deriving
29
54
  * the byte cap from the entry cap removes that contradiction at the source.
30
55
  */
31
- export const PER_ENTRY_BYTE_ALLOWANCE = 600;
56
+ export const PER_ENTRY_BYTE_ALLOWANCE = LEGACY_LEARNINGS_MAX_TOKENS / MAX_ENTRIES +
57
+ FINGERPRINT_FIELD_BYTE_OVERHEAD +
58
+ MAX_STABLE_TOKEN_BYTES;
32
59
  export const LEARNINGS_CONTRACT = Object.freeze({
33
- version: 1,
60
+ version: 2,
34
61
  fields: Object.freeze([
35
62
  "id",
63
+ "fingerprint",
36
64
  "rule",
37
65
  "why",
38
66
  "provenance",
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-contract.js","sourceRoot":"","sources":["../../src/core/learnings-contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAK7E,4DAA4D;AAC5D,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,IAAI;QACJ,MAAM;QACN,KAAK;QACL,YAAY;QACZ,eAAe;QACf,gBAAgB;QAChB,YAAY;KACJ,CAAC;IACX,iBAAiB,EAAE,GAAG;IACtB,YAAY,EAAE,CAAC;IACf,uBAAuB,EAAE,EAAE;IAC3B,UAAU,EAAE,WAAW;IACvB,SAAS,EAAE,WAAW,GAAG,wBAAwB;IACjD,WAAW,EAAE,wBAAwB;CAC7B,CAAC,CAAC;AAaZ;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC"}
1
+ {"version":3,"file":"learnings-contract.js","sourceRoot":"","sources":["../../src/core/learnings-contract.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,C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AGNOSIS = "Project learnings file contain
11
11
  * @returns Canonical Markdown plus JSONL document
12
12
  */
13
13
  export declare function renderLearningsFile(entries: readonly LearningEntry[]): string;
14
+ /** Metadata-preserving parse result for one supported source version. */
15
+ export interface ParsedLearningsDocument {
16
+ /** Contract version declared by the source bytes. */
17
+ readonly sourceVersion: 1 | 2;
18
+ /** Entries normalized to the current exact eight-field schema. */
19
+ readonly entries: readonly LearningEntry[];
20
+ /** Whether the bytes are canonical for their declared source version. */
21
+ readonly canonicalSource: boolean;
22
+ /** Byte ceiling that governed the source version before normalization. */
23
+ readonly sourceMaxTokens: number;
24
+ }
14
25
  /**
15
26
  * Parse and revalidate an existing file before it participates in a write.
16
27
  * @param content - Existing learnings document
17
28
  * @returns Revalidated entries from the document
18
29
  */
19
30
  export declare function parseLearningsFile(content: string): LearningEntry[];
31
+ /**
32
+ * Parse a v1 or v2 document while retaining the source-version facts writers
33
+ * need to migrate only when they already have a reason to mutate.
34
+ * @param content - Existing learnings document
35
+ * @returns Normalized entries plus source-version and canonicality metadata
36
+ */
37
+ export declare function parseLearningsDocument(content: string): ParsedLearningsDocument;
20
38
  /**
21
39
  * A document that does not fit the hard entry-count or token budget.
22
40
  *
@@ -40,8 +58,9 @@ export declare class LearningsBudgetError extends Error {
40
58
  * @param content - Canonical document
41
59
  * @param entryCount - Number of entries in the document
42
60
  * @param context - Error-message prefix
61
+ * @param maxTokens - Source-version byte ceiling to enforce
43
62
  */
44
- export declare function assertDocumentBudget(content: string, entryCount: number, context: string): void;
63
+ export declare function assertDocumentBudget(content: string, entryCount: number, context: string, maxTokens?: number): void;
45
64
  /**
46
65
  * Locate the first line git left a conflict marker on.
47
66
  *
@@ -1 +1 @@
1
- {"version":3,"file":"learnings-document.d.ts","sourceRoot":"","sources":["../../src/core/learnings-document.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AA+BjC;;;GAGG;AACH,eAAO,MAAM,yBAAyB,0DACmB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAG7E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CA8BnE;AAED;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,IAAI,CAYN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAIvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,UAAU,GACjB,MAAM,GAAG,SAAS,CAEpB"}
1
+ {"version":3,"file":"learnings-document.d.ts","sourceRoot":"","sources":["../../src/core/learnings-document.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAsCjC;;;GAGG;AACH,eAAO,MAAM,yBAAyB,0DACmB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAG7E;AAED,yEAAyE;AACzE,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,yEAAyE;IACzE,QAAQ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