@jungjaehoon/mama-core 1.4.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -10
- package/db/migrations/026-create-canonical-entity-tables.sql +99 -0
- package/db/migrations/027-create-entity-review-support.sql +44 -0
- package/db/migrations/028-create-entity-audit-tables.sql +45 -0
- package/db/migrations/029-extend-entity-observations-observation-type.sql +60 -0
- package/db/migrations/030-case-first-memory-substrate.sql +901 -0
- package/db/migrations/031-wiki-page-index-provenance-columns.sql +2 -0
- package/db/migrations/032-add-memory-provenance-columns.sql +21 -0
- package/db/migrations/033-create-model-runs-and-tool-traces.sql +53 -0
- package/db/migrations/034-add-connector-event-scope-columns.sql +14 -0
- package/db/migrations/035-create-twin-edges.sql +63 -0
- package/db/migrations/036-create-agent-situation-packets.sql +61 -0
- package/dist/agent-graph/alias-write.d.ts +3 -0
- package/dist/agent-graph/alias-write.js +231 -0
- package/dist/agent-graph/entity-resolve.d.ts +3 -0
- package/dist/agent-graph/entity-resolve.js +275 -0
- package/dist/agent-graph/errors.d.ts +4 -0
- package/dist/agent-graph/errors.js +11 -0
- package/dist/agent-graph/graph-query.d.ts +5 -0
- package/dist/agent-graph/graph-query.js +359 -0
- package/dist/agent-graph/index.d.ts +6 -0
- package/dist/agent-graph/index.js +22 -0
- package/dist/agent-graph/types.d.ts +162 -0
- package/dist/agent-graph/types.js +3 -0
- package/dist/agent-situation/builder.d.ts +8 -0
- package/dist/agent-situation/builder.js +239 -0
- package/dist/agent-situation/cache-key.d.ts +4 -0
- package/dist/agent-situation/cache-key.js +64 -0
- package/dist/agent-situation/index.d.ts +7 -0
- package/dist/agent-situation/index.js +28 -0
- package/dist/agent-situation/packet-store.d.ts +27 -0
- package/dist/agent-situation/packet-store.js +228 -0
- package/dist/agent-situation/ranking-policy.d.ts +18 -0
- package/dist/agent-situation/ranking-policy.js +75 -0
- package/dist/agent-situation/source-readers.d.ts +52 -0
- package/dist/agent-situation/source-readers.js +300 -0
- package/dist/agent-situation/types.d.ts +195 -0
- package/dist/agent-situation/types.js +3 -0
- package/dist/canonicalize.d.ts +38 -0
- package/dist/canonicalize.js +106 -0
- package/dist/cases/case-links.d.ts +116 -0
- package/dist/cases/case-links.js +794 -0
- package/dist/cases/composition-overrides.d.ts +90 -0
- package/dist/cases/composition-overrides.js +724 -0
- package/dist/cases/corrections.d.ts +156 -0
- package/dist/cases/corrections.js +1045 -0
- package/dist/cases/freshness.d.ts +57 -0
- package/dist/cases/freshness.js +283 -0
- package/dist/cases/live-state.d.ts +48 -0
- package/dist/cases/live-state.js +256 -0
- package/dist/cases/membership-explain.d.ts +56 -0
- package/dist/cases/membership-explain.js +140 -0
- package/dist/cases/membership-matcher.d.ts +23 -0
- package/dist/cases/membership-matcher.js +193 -0
- package/dist/cases/merge-split.d.ts +61 -0
- package/dist/cases/merge-split.js +368 -0
- package/dist/cases/role-inference.d.ts +10 -0
- package/dist/cases/role-inference.js +85 -0
- package/dist/cases/search-rollup.d.ts +27 -0
- package/dist/cases/search-rollup.js +309 -0
- package/dist/cases/sqlite-transaction.d.ts +10 -0
- package/dist/cases/sqlite-transaction.js +62 -0
- package/dist/cases/store.d.ts +74 -0
- package/dist/cases/store.js +816 -0
- package/dist/cases/target-ref.d.ts +25 -0
- package/dist/cases/target-ref.js +22 -0
- package/dist/cases/timeline-range.d.ts +6 -0
- package/dist/cases/timeline-range.js +322 -0
- package/dist/cases/tombstone-sweeper.d.ts +13 -0
- package/dist/cases/tombstone-sweeper.js +128 -0
- package/dist/cases/types.d.ts +244 -0
- package/dist/cases/types.js +47 -0
- package/dist/cases/wiki-page-index.d.ts +50 -0
- package/dist/cases/wiki-page-index.js +350 -0
- package/dist/connectors/event-index.d.ts +45 -0
- package/dist/connectors/event-index.js +381 -0
- package/dist/connectors/raw-query.d.ts +18 -0
- package/dist/connectors/raw-query.js +305 -0
- package/dist/connectors/types.d.ts +109 -0
- package/dist/connectors/types.js +3 -0
- package/dist/db-adapter/node-sqlite-adapter.d.ts +6 -0
- package/dist/db-adapter/node-sqlite-adapter.js +131 -0
- package/dist/db-manager.d.ts +12 -1
- package/dist/db-manager.js +60 -5
- package/dist/decision-formatter.d.ts +2 -0
- package/dist/decision-formatter.js +11 -8
- package/dist/edges/ref-validation.d.ts +8 -0
- package/dist/edges/ref-validation.js +262 -0
- package/dist/edges/store.d.ts +10 -0
- package/dist/edges/store.js +343 -0
- package/dist/edges/types.d.ts +86 -0
- package/dist/edges/types.js +18 -0
- package/dist/embedding-server/mobile/daemon.d.ts +1 -0
- package/dist/embedding-server/mobile/daemon.js +11 -1
- package/dist/embeddings.js +13 -0
- package/dist/entities/audit-metrics.d.ts +73 -0
- package/dist/entities/audit-metrics.js +128 -0
- package/dist/entities/candidate-generator.d.ts +9 -0
- package/dist/entities/candidate-generator.js +436 -0
- package/dist/entities/entity-impact.d.ts +41 -0
- package/dist/entities/entity-impact.js +140 -0
- package/dist/entities/entity-linked-decision-counts.d.ts +2 -0
- package/dist/entities/entity-linked-decision-counts.js +29 -0
- package/dist/entities/entity-list.d.ts +23 -0
- package/dist/entities/entity-list.js +99 -0
- package/dist/entities/entity-orphan-list.d.ts +26 -0
- package/dist/entities/entity-orphan-list.js +91 -0
- package/dist/entities/entity-search.d.ts +21 -0
- package/dist/entities/entity-search.js +150 -0
- package/dist/entities/errors.d.ts +65 -0
- package/dist/entities/errors.js +124 -0
- package/dist/entities/exact-merge-backfill.d.ts +11 -0
- package/dist/entities/exact-merge-backfill.js +161 -0
- package/dist/entities/lineage-backfill.d.ts +12 -0
- package/dist/entities/lineage-backfill.js +101 -0
- package/dist/entities/lineage-store.d.ts +51 -0
- package/dist/entities/lineage-store.js +308 -0
- package/dist/entities/normalization.d.ts +14 -0
- package/dist/entities/normalization.js +63 -0
- package/dist/entities/policy-store.d.ts +17 -0
- package/dist/entities/policy-store.js +263 -0
- package/dist/entities/policy-types.d.ts +72 -0
- package/dist/entities/policy-types.js +59 -0
- package/dist/entities/projection.d.ts +8 -0
- package/dist/entities/projection.js +82 -0
- package/dist/entities/provenance-query.d.ts +33 -0
- package/dist/entities/provenance-query.js +167 -0
- package/dist/entities/read-identity.d.ts +31 -0
- package/dist/entities/read-identity.js +264 -0
- package/dist/entities/recall-bridge.d.ts +5 -0
- package/dist/entities/recall-bridge.js +171 -0
- package/dist/entities/resolution-engine.d.ts +15 -0
- package/dist/entities/resolution-engine.js +69 -0
- package/dist/entities/rollback-preview.d.ts +39 -0
- package/dist/entities/rollback-preview.js +235 -0
- package/dist/entities/source-locator.d.ts +3 -0
- package/dist/entities/source-locator.js +32 -0
- package/dist/entities/store.d.ts +75 -0
- package/dist/entities/store.js +465 -0
- package/dist/entities/types.d.ts +162 -0
- package/dist/entities/types.js +30 -0
- package/dist/index.d.ts +62 -3
- package/dist/index.js +116 -26
- package/dist/mama-api.d.ts +53 -35
- package/dist/mama-api.js +437 -78
- package/dist/memory/api.d.ts +26 -38
- package/dist/memory/api.js +772 -68
- package/dist/memory/event-store.d.ts +3 -0
- package/dist/memory/event-store.js +21 -2
- package/dist/memory/provenance-audit.d.ts +22 -0
- package/dist/memory/provenance-audit.js +112 -0
- package/dist/memory/provenance-query.d.ts +11 -0
- package/dist/memory/provenance-query.js +193 -0
- package/dist/memory/provenance.d.ts +29 -0
- package/dist/memory/provenance.js +136 -0
- package/dist/memory/scope-backfill.d.ts +17 -0
- package/dist/memory/scope-backfill.js +77 -0
- package/dist/memory/types.d.ts +97 -16
- package/dist/model-runs/store.d.ts +13 -0
- package/dist/model-runs/store.js +457 -0
- package/dist/model-runs/tool-trace-store.d.ts +4 -0
- package/dist/model-runs/tool-trace-store.js +114 -0
- package/dist/model-runs/types.d.ts +69 -0
- package/dist/model-runs/types.js +5 -0
- package/dist/runtime/trusted-provenance.d.ts +3 -0
- package/dist/runtime/trusted-provenance.js +6 -0
- package/dist/search/feedback-store.d.ts +59 -0
- package/dist/search/feedback-store.js +211 -0
- package/dist/search/question-type.d.ts +5 -0
- package/dist/search/question-type.js +41 -0
- package/dist/search/ranker-features.d.ts +23 -0
- package/dist/search/ranker-features.js +104 -0
- package/dist/search/ranker-rescore.d.ts +31 -0
- package/dist/search/ranker-rescore.js +226 -0
- package/dist/search/ranker-trainer.d.ts +94 -0
- package/dist/search/ranker-trainer.js +860 -0
- package/dist/search/search-quality.d.ts +36 -0
- package/dist/search/search-quality.js +29 -0
- package/dist/test-utils.d.ts +14 -0
- package/dist/test-utils.js +52 -0
- package/package.json +28 -3
|
@@ -0,0 +1,156 @@
|
|
|
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
|