@dreamforgestudiollc/emet 0.3.5 → 0.3.7

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 (103) hide show
  1. package/.env.example +29 -0
  2. package/CHANGELOG.md +49 -11
  3. package/CHARTER.md +1 -1
  4. package/CONTRIBUTING.md +21 -0
  5. package/README.md +25 -10
  6. package/RELEASE_NOTES-0.2.6.md +43 -0
  7. package/RELEASE_NOTES-0.3.6.md +29 -0
  8. package/RELEASE_NOTES-0.3.7.md +19 -0
  9. package/SECURITY.md +13 -0
  10. package/docs/BOTS.md +4 -4
  11. package/docs/DEPLOY.md +23 -4
  12. package/docs/ERROR-CODES-SPEC.md +4 -0
  13. package/docs/ERROR-CODES.md +7 -0
  14. package/docs/GUIDED-SETUP.md +1 -1
  15. package/docs/ROADMAP.md +62 -49
  16. package/docs/SETUP.md +11 -1
  17. package/docs/SUBKEYS.md +3 -1
  18. package/docs/continuity-currency-statechart.md +34 -0
  19. package/docs/features/README.md +21 -0
  20. package/docs/features/access.md +28 -0
  21. package/docs/features/documents.md +35 -0
  22. package/docs/features/errors.md +32 -0
  23. package/docs/features/gems.md +31 -0
  24. package/docs/features/memory.md +29 -0
  25. package/docs/features/pages.md +28 -0
  26. package/docs/features/record.md +27 -0
  27. package/docs/features/search.md +27 -0
  28. package/docs/features/startup.md +29 -0
  29. package/docs/features/subkeys.md +30 -0
  30. package/docs/features/transcripts.md +33 -0
  31. package/docs/per-tag-handoff-statechart.md +147 -0
  32. package/docs/subkey-session-statechart.md +57 -0
  33. package/package.json +6 -2
  34. package/server.json +27 -2
  35. package/src/annotations.js +5 -3
  36. package/src/attribution.js +2 -2
  37. package/src/carry-forward-close.js +1 -1
  38. package/src/chooser.js +74 -3
  39. package/src/conformance.js +2 -0
  40. package/src/continuity-currency-statechart.js +139 -0
  41. package/src/continuity-currency.js +869 -0
  42. package/src/database.js +1 -1
  43. package/src/dispatch.js +1 -1
  44. package/src/error-codes.js +7 -0
  45. package/src/gem-check.js +4 -1
  46. package/src/grants.js +28 -5
  47. package/src/host-reach.js +1 -1
  48. package/src/http-remote.js +29 -5
  49. package/src/index.js +3 -2
  50. package/src/invites.js +2 -2
  51. package/src/owl.js +12 -11
  52. package/src/pages.js +15 -0
  53. package/src/per-tag-handoff-statechart.js +264 -0
  54. package/src/per-tag-handoff.js +988 -0
  55. package/src/persons.js +16 -0
  56. package/src/session-graph.js +123 -12
  57. package/src/session.js +56 -12
  58. package/src/setup.js +32 -11
  59. package/src/startup-pages.js +13 -2
  60. package/src/subkey-lifecycle.js +105 -0
  61. package/src/subkey-session-statechart.js +253 -0
  62. package/src/subkeys.js +648 -89
  63. package/src/tools.js +171 -51
  64. package/src/transcript-session.js +2 -2
  65. package/src/version.js +1 -1
  66. package/templates/INDEX.md +1 -0
  67. package/templates/SESSIONDISPOSITION.md +2 -2
  68. package/templates/TAGHANDOFF.md +45 -0
  69. package/verification/continuity-currency/ContinuityCurrency.cfg +12 -0
  70. package/verification/continuity-currency/ContinuityCurrency.tla +239 -0
  71. package/verification/continuity-currency/tlc-output.txt +32 -0
  72. package/verification/continuity-currency/view.mjs +54 -0
  73. package/verification/load-gate/load-gate.mjs +1 -1
  74. package/verification/per-tag-handoff/PerTagHandoff.cfg +10 -0
  75. package/verification/per-tag-handoff/PerTagHandoff.tla +191 -0
  76. package/verification/per-tag-handoff/StampCounter.cfg +10 -0
  77. package/verification/per-tag-handoff/out/report.md +6 -0
  78. package/verification/per-tag-handoff/out-counter/chart.mmd +30 -0
  79. package/verification/per-tag-handoff/out-counter/report.md +15 -0
  80. package/verification/per-tag-handoff/out-counter/tlc.out +130 -0
  81. package/verification/per-tag-handoff/split/PerTagConflict.cfg +6 -0
  82. package/verification/per-tag-handoff/split/PerTagConflict.tla +104 -0
  83. package/verification/per-tag-handoff/split/PerTagTime.cfg +8 -0
  84. package/verification/per-tag-handoff/split/PerTagTime.tla +100 -0
  85. package/verification/per-tag-handoff/split/conflict-chart.mmd +47 -0
  86. package/verification/per-tag-handoff/split/conflict-report.md +8 -0
  87. package/verification/per-tag-handoff/split/conflict-tlc.txt +19 -0
  88. package/verification/per-tag-handoff/split/conflict-view.mjs +34 -0
  89. package/verification/per-tag-handoff/split/time-chart.mmd +44 -0
  90. package/verification/per-tag-handoff/split/time-report.md +8 -0
  91. package/verification/per-tag-handoff/split/time-tlc.txt +19 -0
  92. package/verification/per-tag-handoff/split/time-view.mjs +33 -0
  93. package/verification/per-tag-handoff/tlc-output.txt +19 -0
  94. package/verification/per-tag-handoff/v1-draft/PerTagHandoff.cfg +5 -0
  95. package/verification/per-tag-handoff/v1-draft/PerTagHandoff.tla +94 -0
  96. package/verification/per-tag-handoff/v1-draft/out/chart.mmd +37 -0
  97. package/verification/per-tag-handoff/v1-draft/out/report.md +7 -0
  98. package/verification/per-tag-handoff/v1-draft/out/tlc.out +19 -0
  99. package/verification/per-tag-handoff/v1-draft/view.mjs +20 -0
  100. package/verification/per-tag-handoff/view.mjs +31 -0
  101. package/verification/subkey-session/SubkeySession.cfg +11 -0
  102. package/verification/subkey-session/SubkeySession.tla +254 -0
  103. package/verification/subkey-session/tlc-output.txt +13 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * EMET - Enduring Memory & Epistemic Tiers
3
+ * Copyright (c) 2026 Dreamforge Studio LLC
4
+ *
5
+ * Licensed under the MIT License - see LICENSE
6
+ *
7
+ * Continuity-currency (tip-lag) statechart. Warn, current, documented
8
+ * no-op, no handoff, unreadable, or fallback-only. The gate does not rewrite
9
+ * HANDOFF or STATE and does not block. This is not the wiki page-currency
10
+ * diagram. Served on /statechart. The same picture is
11
+ * docs/continuity-currency-statechart.md. The model is
12
+ * verification/continuity-currency/ContinuityCurrency.tla. It does not
13
+ * enumerate episodic ids.
14
+ */
15
+
16
+ export const CONTINUITY_CURRENCY_MERMAID = `stateDiagram-v2
17
+ [*] --> GateOff
18
+ GateOff --> GateOff: warn flag stays off
19
+ GateOff --> Comparing: warn flag on
20
+ Comparing --> Current: handoff cites the live material tip
21
+ Comparing --> DocumentedNoOp: documented no-op, no newer material tip
22
+ Comparing --> Current: newer episodic is scratch or diagnosis only
23
+ Comparing --> Current: version number alone
24
+ Comparing --> Warning: material tip is newer
25
+ Comparing --> FallbackOnly: only a fallback tip is newer
26
+ Comparing --> NoHandoff: no handoff to compare
27
+ Comparing --> Unreadable: the comparison could not be read
28
+ Warning --> BlockHeld: block asked, still does not block
29
+ FallbackOnly --> FallbackHeld: block asked, still does not block
30
+ Warning --> Comparing: the next initialize compares again
31
+ Current --> Comparing: the next initialize compares again
32
+ DocumentedNoOp --> Comparing: the next initialize compares again
33
+ BlockHeld --> Comparing: the next initialize compares again
34
+ FallbackOnly --> Comparing: the next initialize compares again
35
+ FallbackHeld --> Comparing: the next initialize compares again
36
+ NoHandoff --> Comparing: the next initialize compares again
37
+ Unreadable --> Comparing: the next initialize compares again`;
38
+
39
+ export const CONTINUITY_CURRENCY_STEPS = Object.freeze([
40
+ 'The warn flag starts off. Initialize serves HANDOFF as it does today and shows no continuity-currency warning.',
41
+ 'With the warn flag on, initialize compares the served HANDOFF to the live material episodic tip. The comparison does not write.',
42
+ 'A handoff that cites the live material tip is current. A newer scratch or diagnosis-only episodic does not warn. A version number alone does not warn.',
43
+ 'A documented no-op has no newer material tip. The handoff version may stay where it is. That is not a warning.',
44
+ 'When the material tip is newer, initialize returns a warning with the lag. The call is not blocked.',
45
+ 'A fallback-only tip is a warning and is not block-eligible. Asking for the phase-2 block still does not block.',
46
+ 'No handoff, or a comparison that could not be read, shows that status and does not warn. Nothing is written.',
47
+ 'Asking for the phase-2 block leaves the warning in place and still does not block. HANDOFF and STATE stay untouched. The host rewrites HANDOFF whole.'
48
+ ]);
49
+
50
+ const PHASES = new Set([
51
+ 'GateOff', 'Comparing', 'Current', 'DocumentedNoOp', 'Warning', 'BlockHeld',
52
+ 'NoHandoff', 'Unreadable', 'FallbackOnly', 'FallbackHeld'
53
+ ]);
54
+ const COMPARE_AGAIN = new Set([
55
+ 'Current', 'DocumentedNoOp', 'Warning', 'BlockHeld',
56
+ 'NoHandoff', 'Unreadable', 'FallbackOnly', 'FallbackHeld'
57
+ ]);
58
+
59
+ function blank(state, extra = {}) {
60
+ return {
61
+ phase: state.phase,
62
+ flag: state.flag,
63
+ newer: state.newer,
64
+ claim: state.claim,
65
+ blockEligible: false,
66
+ handoffMutated: false,
67
+ blocked: false,
68
+ warning: false,
69
+ ...extra,
70
+ handoffMutated: false,
71
+ blocked: false
72
+ };
73
+ }
74
+
75
+ /**
76
+ * One step of the diagram. An event that cannot happen in this phase returns
77
+ * null. `handoffMutated` and `blocked` stay false on every step.
78
+ */
79
+ export function continuityCurrencyStep(state, event) {
80
+ if (!state || !PHASES.has(state.phase)) return null;
81
+ if (!event || typeof event.type !== 'string') return null;
82
+ if (event.type === 'flag_off') {
83
+ if (state.flag !== 'off' || state.phase !== 'GateOff') return null;
84
+ return blank(state, { phase: 'GateOff', warning: false });
85
+ }
86
+ if (event.type === 'enable') {
87
+ if (state.flag !== 'off' || state.phase !== 'GateOff') return null;
88
+ return blank(state, { phase: 'Comparing', flag: 'warn', warning: false });
89
+ }
90
+ if (event.type === 'cite_tip' || event.type === 'scratch' || event.type === 'version_only' || event.type === 'no_op' || event.type === 'material_lag' || event.type === 'fallback_only' || event.type === 'no_handoff' || event.type === 'unreadable') {
91
+ if (state.flag !== 'warn' || state.phase !== 'Comparing') return null;
92
+ if (event.type === 'cite_tip') return blank(state, { phase: 'Current', newer: 'none', claim: 'at_tip' });
93
+ if (event.type === 'scratch') return blank(state, { phase: 'Current', newer: 'scratch', claim: 'at_tip' });
94
+ if (event.type === 'version_only') return blank(state, { phase: 'Current', newer: 'material', claim: 'version_only' });
95
+ if (event.type === 'no_op') return blank(state, { phase: 'DocumentedNoOp', newer: 'none', claim: 'at_tip' });
96
+ if (event.type === 'no_handoff') return blank(state, { phase: 'NoHandoff', newer: 'none', claim: 'at_tip' });
97
+ if (event.type === 'unreadable') return blank(state, { phase: 'Unreadable', newer: 'none', claim: 'at_tip' });
98
+ if (event.type === 'fallback_only') {
99
+ return blank(state, { phase: 'FallbackOnly', newer: 'fallback', claim: 'behind', warning: true, blockEligible: false });
100
+ }
101
+ return blank(state, { phase: 'Warning', newer: 'material', claim: 'behind', warning: true, blockEligible: true });
102
+ }
103
+ if (event.type === 'ask_block') {
104
+ if (state.phase === 'Warning') {
105
+ return blank(state, { phase: 'BlockHeld', newer: 'material', claim: 'behind', warning: true, blockEligible: true });
106
+ }
107
+ if (state.phase === 'FallbackOnly') {
108
+ return blank(state, { phase: 'FallbackHeld', newer: 'fallback', claim: 'behind', warning: true, blockEligible: false });
109
+ }
110
+ return null;
111
+ }
112
+ if (event.type === 'initialize_again') {
113
+ if (state.flag !== 'warn' || !COMPARE_AGAIN.has(state.phase)) return null;
114
+ return blank(state, { phase: 'Comparing', warning: false, blockEligible: false });
115
+ }
116
+ return null;
117
+ }
118
+
119
+ /** The rules the diagram states. A rewrite or a block breaks the invariant. */
120
+ export function continuityCurrencyInvariant(state) {
121
+ if (!state || state.handoffMutated !== false) return false;
122
+ if (state.blocked !== false) return false;
123
+ if (state.flag === 'off' && (state.phase !== 'GateOff' || state.warning !== false)) return false;
124
+ if (state.warning === true) {
125
+ const material = (state.phase === 'Warning' || state.phase === 'BlockHeld')
126
+ && state.newer === 'material' && state.claim === 'behind' && state.blockEligible === true;
127
+ const fallback = (state.phase === 'FallbackOnly' || state.phase === 'FallbackHeld')
128
+ && state.newer === 'fallback' && state.claim === 'behind' && state.blockEligible !== true;
129
+ if (!material && !fallback) return false;
130
+ }
131
+ if (state.phase === 'DocumentedNoOp' && state.warning !== false) return false;
132
+ if (state.phase === 'NoHandoff' && state.warning !== false) return false;
133
+ if (state.phase === 'Unreadable' && state.warning !== false) return false;
134
+ if (state.newer === 'scratch' && state.warning !== false) return false;
135
+ if (state.newer === 'fallback' && (state.blocked !== false || state.blockEligible === true)) return false;
136
+ if (state.claim === 'version_only' && state.warning !== false) return false;
137
+ if ((state.phase === 'Warning' || state.phase === 'BlockHeld' || state.phase === 'FallbackOnly' || state.phase === 'FallbackHeld') && state.blocked !== false) return false;
138
+ return true;
139
+ }