@jungjaehoon/mama-core 1.9.0 → 2.1.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 (139) hide show
  1. package/db/migrations/043-add-tool-trace-failure-code.sql +11 -0
  2. package/dist/agent-graph/alias-write.js +3 -0
  3. package/dist/agent-graph/entity-resolve.js +3 -7
  4. package/dist/agent-graph/graph-query.js +5 -4
  5. package/dist/agent-graph/types.d.ts +30 -0
  6. package/dist/cases/store.d.ts +0 -4
  7. package/dist/cases/store.js +0 -66
  8. package/dist/cases/wiki-page-index.d.ts +0 -13
  9. package/dist/cases/wiki-page-index.js +0 -153
  10. package/dist/connectors/event-index.d.ts +1 -22
  11. package/dist/connectors/event-index.js +0 -157
  12. package/dist/context-compile/channel-grant.d.ts +46 -0
  13. package/dist/context-compile/channel-grant.js +66 -0
  14. package/dist/context-compile/compiler.js +5 -2
  15. package/dist/context-compile/index.d.ts +1 -0
  16. package/dist/context-compile/index.js +1 -0
  17. package/dist/context-compile/packet-store.d.ts +0 -1
  18. package/dist/context-compile/packet-store.js +0 -16
  19. package/dist/context-compile/source-readers.d.ts +1 -0
  20. package/dist/context-compile/source-readers.js +156 -23
  21. package/dist/context-compile/types.d.ts +17 -0
  22. package/dist/context-compile/visibility.js +28 -4
  23. package/dist/db-adapter/node-sqlite-adapter.js +4 -0
  24. package/dist/db-manager.d.ts +0 -13
  25. package/dist/db-manager.js +0 -66
  26. package/dist/decision-formatter.d.ts +0 -11
  27. package/dist/decision-formatter.js +0 -122
  28. package/dist/decision-tracker.d.ts +0 -12
  29. package/dist/decision-tracker.js +0 -50
  30. package/dist/edges/ref-validation.d.ts +1 -2
  31. package/dist/edges/ref-validation.js +33 -13
  32. package/dist/edges/store.d.ts +1 -3
  33. package/dist/edges/store.js +0 -214
  34. package/dist/edges/types.d.ts +10 -0
  35. package/dist/embedding-client.d.ts +0 -17
  36. package/dist/embedding-client.js +0 -80
  37. package/dist/embedding-server/mobile/auth.d.ts +1 -10
  38. package/dist/embedding-server/mobile/auth.js +0 -15
  39. package/dist/embeddings.d.ts +0 -12
  40. package/dist/embeddings.js +0 -68
  41. package/dist/entities/audit-metrics.d.ts +0 -5
  42. package/dist/entities/audit-metrics.js +0 -4
  43. package/dist/entities/candidate-generator.d.ts +1 -2
  44. package/dist/entities/candidate-generator.js +0 -412
  45. package/dist/entities/entity-list.d.ts +0 -1
  46. package/dist/entities/entity-list.js +0 -96
  47. package/dist/entities/entity-orphan-list.d.ts +0 -9
  48. package/dist/entities/entity-orphan-list.js +0 -88
  49. package/dist/entities/entity-search.d.ts +0 -1
  50. package/dist/entities/entity-search.js +0 -147
  51. package/dist/entities/errors.d.ts +0 -10
  52. package/dist/entities/errors.js +1 -25
  53. package/dist/entities/lineage-store.d.ts +0 -23
  54. package/dist/entities/lineage-store.js +0 -104
  55. package/dist/entities/policy-store.d.ts +0 -9
  56. package/dist/entities/policy-store.js +0 -188
  57. package/dist/entities/provenance-query.d.ts +0 -1
  58. package/dist/entities/provenance-query.js +0 -164
  59. package/dist/entities/resolution-engine.d.ts +1 -8
  60. package/dist/entities/resolution-engine.js +0 -66
  61. package/dist/entities/rollback-preview.d.ts +0 -4
  62. package/dist/entities/rollback-preview.js +0 -232
  63. package/dist/entities/store.d.ts +1 -10
  64. package/dist/entities/store.js +0 -49
  65. package/dist/index.d.ts +15 -31
  66. package/dist/index.js +4 -46
  67. package/dist/mama-api.d.ts +19 -1
  68. package/dist/mama-api.js +97 -2
  69. package/dist/memory/api.d.ts +8 -0
  70. package/dist/memory/api.js +55 -2
  71. package/dist/memory/event-store.d.ts +0 -1
  72. package/dist/memory/event-store.js +0 -15
  73. package/dist/memory/finding-store.d.ts +0 -1
  74. package/dist/memory/finding-store.js +0 -12
  75. package/dist/memory/scope-backfill.d.ts +0 -3
  76. package/dist/memory/scope-backfill.js +0 -74
  77. package/dist/memory/scope-store.d.ts +0 -1
  78. package/dist/memory/scope-store.js +0 -4
  79. package/dist/memory/truth-store.d.ts +0 -3
  80. package/dist/memory/truth-store.js +0 -22
  81. package/dist/memory/types.d.ts +0 -1
  82. package/dist/memory/types.js +0 -13
  83. package/dist/memory-store.d.ts +0 -16
  84. package/dist/memory-store.js +0 -51
  85. package/dist/model-runs/tool-trace-store.js +9 -5
  86. package/dist/model-runs/types.d.ts +3 -0
  87. package/dist/ollama-client.d.ts +0 -9
  88. package/dist/ollama-client.js +0 -125
  89. package/dist/outcome-tracker.d.ts +0 -14
  90. package/dist/outcome-tracker.js +0 -44
  91. package/dist/progress-indicator.d.ts +0 -4
  92. package/dist/progress-indicator.js +0 -7
  93. package/dist/provenance/source-ref.d.ts +0 -9
  94. package/dist/provenance/source-ref.js +0 -145
  95. package/dist/query-intent.d.ts +0 -4
  96. package/dist/query-intent.js +0 -30
  97. package/dist/relevance-scorer.d.ts +0 -9
  98. package/dist/relevance-scorer.js +0 -81
  99. package/dist/search/feedback-store.d.ts +0 -1
  100. package/dist/search/feedback-store.js +0 -4
  101. package/dist/search/ranker-rescore.d.ts +0 -3
  102. package/dist/search/ranker-rescore.js +0 -27
  103. package/dist/search/ranker-trainer.d.ts +0 -8
  104. package/dist/search/ranker-trainer.js +0 -376
  105. package/dist/tier-validator.d.ts +0 -12
  106. package/dist/tier-validator.js +0 -56
  107. package/package.json +1 -10
  108. package/dist/cases/case-links.d.ts +0 -116
  109. package/dist/cases/case-links.js +0 -794
  110. package/dist/cases/composition-overrides.d.ts +0 -90
  111. package/dist/cases/composition-overrides.js +0 -724
  112. package/dist/cases/corrections.d.ts +0 -156
  113. package/dist/cases/corrections.js +0 -1045
  114. package/dist/cases/freshness.d.ts +0 -57
  115. package/dist/cases/freshness.js +0 -283
  116. package/dist/cases/live-state.d.ts +0 -48
  117. package/dist/cases/live-state.js +0 -256
  118. package/dist/cases/membership-explain.d.ts +0 -56
  119. package/dist/cases/membership-explain.js +0 -140
  120. package/dist/cases/membership-matcher.d.ts +0 -23
  121. package/dist/cases/membership-matcher.js +0 -193
  122. package/dist/cases/merge-split.d.ts +0 -61
  123. package/dist/cases/merge-split.js +0 -368
  124. package/dist/cases/role-inference.d.ts +0 -10
  125. package/dist/cases/role-inference.js +0 -85
  126. package/dist/cases/sqlite-transaction.d.ts +0 -10
  127. package/dist/cases/sqlite-transaction.js +0 -62
  128. package/dist/cases/target-ref.d.ts +0 -25
  129. package/dist/cases/target-ref.js +0 -22
  130. package/dist/cases/tombstone-sweeper.d.ts +0 -13
  131. package/dist/cases/tombstone-sweeper.js +0 -128
  132. package/dist/entities/entity-impact.d.ts +0 -41
  133. package/dist/entities/entity-impact.js +0 -140
  134. package/dist/entities/exact-merge-backfill.d.ts +0 -11
  135. package/dist/entities/exact-merge-backfill.js +0 -161
  136. package/dist/entities/lineage-backfill.d.ts +0 -12
  137. package/dist/entities/lineage-backfill.js +0 -101
  138. package/dist/memory-inject.d.ts +0 -24
  139. package/dist/memory-inject.js +0 -116
@@ -1,156 +0,0 @@
1
- import type { DatabaseAdapter } from '../db-manager.js';
2
- import { type CaseTargetRef } from './target-ref.js';
3
- import type { CaseCorrectionRequiresReconfirmResult } from './types.js';
4
- export type CaseCorrectionErrorCode = 'case.precompile_gap' | 'case.correction_requires_reconfirm' | 'case.correction_active_conflict' | 'case.correction_not_found' | 'case.correction_reverted' | 'case.correction_inactive' | 'case.correction_already_superseded' | 'case.supersede_target_mismatch' | 'case.reconfirm_token_invalid' | 'case.reconfirm_token_replayed' | 'case.terminal_status' | 'case.lock_held';
5
- export interface ApplyCorrectionInput {
6
- case_id: string;
7
- target_kind: 'case_field' | 'membership' | 'wiki_section';
8
- target_ref: CaseTargetRef;
9
- field_name?: 'status' | 'status_reason' | 'primary_actors' | 'blockers' | 'confidence';
10
- old_value_json?: string | null;
11
- reconfirm_token?: string | null;
12
- session_id?: string | null;
13
- new_value_json: string;
14
- reason: string;
15
- confirmed: true;
16
- confirmed_by: string;
17
- confirmation_summary: string;
18
- now?: string;
19
- }
20
- export type CorrectionApplyResult = {
21
- kind: 'applied';
22
- correction_id: string;
23
- case_id: string;
24
- target_ref_json: string;
25
- canonical_hash_hex: string;
26
- } | CaseCorrectionRequiresReconfirmResult | {
27
- kind: 'precompile_gap';
28
- code: 'case.precompile_gap';
29
- case_id: string;
30
- } | {
31
- kind: 'rejected';
32
- code: CaseCorrectionErrorCode;
33
- message: string;
34
- case_id: string;
35
- };
36
- export interface RevertCorrectionInput {
37
- correction_id: string;
38
- confirmed: true;
39
- confirmed_by: string;
40
- confirmation_summary: string;
41
- now?: string;
42
- }
43
- export type CorrectionRevertResult = {
44
- kind: 'reverted';
45
- correction_id: string;
46
- case_id: string;
47
- } | {
48
- kind: 'precompile_gap';
49
- code: 'case.precompile_gap';
50
- case_id: string;
51
- } | {
52
- kind: 'rejected';
53
- code: CaseCorrectionErrorCode;
54
- message: string;
55
- correction_id?: string;
56
- };
57
- export interface SupersedeCorrectionInput {
58
- old_correction_id: string;
59
- new_value_json: string;
60
- reason: string;
61
- confirmed: true;
62
- confirmed_by: string;
63
- confirmation_summary: string;
64
- /**
65
- * The current value the user saw in the drawer when they chose to
66
- * supersede. When provided and it disagrees with the live value, the
67
- * helper returns `case.correction_requires_reconfirm`. Omit to skip
68
- * CAS — in that case the caller trusts the active correction as the
69
- * sole source of truth.
70
- */
71
- expected_current_value_json?: string | null;
72
- reconfirm_token?: string | null;
73
- session_id?: string | null;
74
- now?: string;
75
- }
76
- export type CorrectionSupersedeResult = {
77
- kind: 'superseded';
78
- old_correction_id: string;
79
- new_correction_id: string;
80
- case_id: string;
81
- target_ref_json: string;
82
- canonical_hash_hex: string;
83
- } | CaseCorrectionRequiresReconfirmResult | {
84
- kind: 'precompile_gap';
85
- code: 'case.precompile_gap';
86
- case_id: string;
87
- } | {
88
- kind: 'rejected';
89
- code: CaseCorrectionErrorCode;
90
- message: string;
91
- correction_id?: string;
92
- case_id?: string;
93
- };
94
- export interface ReconfirmTokenPayload {
95
- v: 1;
96
- kid: string;
97
- nonce: string;
98
- case_id: string;
99
- target_kind: ApplyCorrectionInput['target_kind'];
100
- target_ref_hash_hex: string;
101
- current_value_hash_hex: string;
102
- proposed_value_hash_hex: string;
103
- confirmed_by: string;
104
- session_id: string | null;
105
- expires_at: string;
106
- }
107
- export interface ReconfirmTokenEnvelope {
108
- kid: string;
109
- payload: ReconfirmTokenPayload;
110
- signature_hex: string;
111
- }
112
- export interface InsertCaseCorrectionLockInput {
113
- correction_id?: string;
114
- case_id: string;
115
- target_kind: ApplyCorrectionInput['target_kind'];
116
- target_ref: CaseTargetRef;
117
- field_name?: ApplyCorrectionInput['field_name'] | null;
118
- old_value_json: string | null;
119
- new_value_json: string;
120
- reason: string;
121
- applied_by: string;
122
- applied_at: string;
123
- is_lock_active?: 0 | 1;
124
- superseded_by?: string | null;
125
- }
126
- export interface InsertCaseCorrectionLockResult {
127
- correction_id: string;
128
- case_id: string;
129
- target_kind: ApplyCorrectionInput['target_kind'];
130
- target_ref_json: string;
131
- target_ref_hash: Uint8Array;
132
- canonical_hash_hex: string;
133
- applied_at: string;
134
- is_lock_active: 0 | 1;
135
- }
136
- export declare function insertCaseCorrectionLock(adapter: DatabaseAdapter, input: InsertCaseCorrectionLockInput): InsertCaseCorrectionLockResult;
137
- export declare function applyCorrection(adapter: DatabaseAdapter, input: ApplyCorrectionInput): CorrectionApplyResult;
138
- export declare function revertCorrection(adapter: DatabaseAdapter, input: RevertCorrectionInput): CorrectionRevertResult;
139
- /**
140
- * supersedeCorrection — Phase 2b. Unblocked by spec amendment-8 (2026-04-18)
141
- * which added `superseded_by` to the mutable-column set in §5.4.
142
- *
143
- * Semantics: user changes their mind on an active correction. Inside a single
144
- * transaction:
145
- * 1. Read OLD row; reject if not found / reverted / already superseded / inactive.
146
- * 2. INSERT new correction row referencing the same (case_id, target_kind,
147
- * target_ref_hash) with new_value_json and is_lock_active=1.
148
- * 3. UPDATE OLD row: superseded_by = new.correction_id, is_lock_active = 0.
149
- * 4. Emit case.correction_superseded memory_event.
150
- *
151
- * Per spec §5.4 invariant (amendment-8), the three mutable columns are
152
- * is_lock_active + reverted_at + superseded_by. superseded_by is written
153
- * ONLY inside this transition.
154
- */
155
- export declare function supersedeCorrection(adapter: DatabaseAdapter, input: SupersedeCorrectionInput): CorrectionSupersedeResult;
156
- //# sourceMappingURL=corrections.d.ts.map