@proposit/proposit-core 0.12.3 → 1.0.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 +104 -93
- package/dist/cli/commands/premises.d.ts.map +1 -1
- package/dist/cli/commands/premises.js +28 -24
- package/dist/cli/commands/premises.js.map +1 -1
- package/dist/cli/commands/repair.d.ts.map +1 -1
- package/dist/cli/commands/repair.js +4 -2
- package/dist/cli/commands/repair.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +7 -1
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/engine.d.ts.map +1 -1
- package/dist/cli/engine.js +7 -25
- package/dist/cli/engine.js.map +1 -1
- package/dist/cli/import.d.ts.map +1 -1
- package/dist/cli/import.js +66 -28
- package/dist/cli/import.js.map +1 -1
- package/dist/lib/core/argument-engine.d.ts +275 -10
- package/dist/lib/core/argument-engine.d.ts.map +1 -1
- package/dist/lib/core/argument-engine.js +442 -82
- package/dist/lib/core/argument-engine.js.map +1 -1
- package/dist/lib/core/argument-library.d.ts +5 -1
- package/dist/lib/core/argument-library.d.ts.map +1 -1
- package/dist/lib/core/argument-library.js +7 -3
- package/dist/lib/core/argument-library.js.map +1 -1
- package/dist/lib/core/expression-manager.d.ts +68 -73
- package/dist/lib/core/expression-manager.d.ts.map +1 -1
- package/dist/lib/core/expression-manager.js +242 -762
- package/dist/lib/core/expression-manager.js.map +1 -1
- package/dist/lib/core/fork.d.ts +5 -1
- package/dist/lib/core/fork.d.ts.map +1 -1
- package/dist/lib/core/fork.js +16 -6
- package/dist/lib/core/fork.js.map +1 -1
- package/dist/lib/core/interfaces/argument-engine.interfaces.d.ts +68 -7
- package/dist/lib/core/interfaces/argument-engine.interfaces.d.ts.map +1 -1
- package/dist/lib/core/interfaces/library.interfaces.d.ts +8 -3
- package/dist/lib/core/interfaces/library.interfaces.d.ts.map +1 -1
- package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts +50 -47
- package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts.map +1 -1
- package/dist/lib/core/premise-engine.d.ts +80 -11
- package/dist/lib/core/premise-engine.d.ts.map +1 -1
- package/dist/lib/core/premise-engine.js +232 -80
- package/dist/lib/core/premise-engine.js.map +1 -1
- package/dist/lib/core/proposit-core.d.ts.map +1 -1
- package/dist/lib/core/proposit-core.js +13 -3
- package/dist/lib/core/proposit-core.js.map +1 -1
- package/dist/lib/grammar/an-rules.d.ts +158 -0
- package/dist/lib/grammar/an-rules.d.ts.map +1 -0
- package/dist/lib/grammar/an-rules.js +778 -0
- package/dist/lib/grammar/an-rules.js.map +1 -0
- package/dist/lib/grammar/auto-normalize.d.ts +14 -0
- package/dist/lib/grammar/auto-normalize.d.ts.map +1 -0
- package/dist/lib/grammar/auto-normalize.js +35 -0
- package/dist/lib/grammar/auto-normalize.js.map +1 -0
- package/dist/lib/grammar/bounded-subtree.d.ts +30 -0
- package/dist/lib/grammar/bounded-subtree.d.ts.map +1 -0
- package/dist/lib/grammar/bounded-subtree.js +74 -0
- package/dist/lib/grammar/bounded-subtree.js.map +1 -0
- package/dist/lib/grammar/naked-q.d.ts +20 -0
- package/dist/lib/grammar/naked-q.d.ts.map +1 -0
- package/dist/lib/grammar/naked-q.js +58 -0
- package/dist/lib/grammar/naked-q.js.map +1 -0
- package/dist/lib/grammar/normalize.d.ts +12 -0
- package/dist/lib/grammar/normalize.d.ts.map +1 -0
- package/dist/lib/grammar/normalize.js +45 -0
- package/dist/lib/grammar/normalize.js.map +1 -0
- package/dist/lib/grammar/populate-from.d.ts +25 -0
- package/dist/lib/grammar/populate-from.d.ts.map +1 -0
- package/dist/lib/grammar/populate-from.js +252 -0
- package/dist/lib/grammar/populate-from.js.map +1 -0
- package/dist/lib/grammar/repair.d.ts +65 -0
- package/dist/lib/grammar/repair.d.ts.map +1 -0
- package/dist/lib/grammar/repair.js +251 -0
- package/dist/lib/grammar/repair.js.map +1 -0
- package/dist/lib/grammar/types.d.ts +17 -0
- package/dist/lib/grammar/types.d.ts.map +1 -0
- package/dist/lib/grammar/types.js +82 -0
- package/dist/lib/grammar/types.js.map +1 -0
- package/dist/lib/grammar/validate.d.ts +4 -0
- package/dist/lib/grammar/validate.d.ts.map +1 -0
- package/dist/lib/grammar/validate.js +28 -0
- package/dist/lib/grammar/validate.js.map +1 -0
- package/dist/lib/grammar/validators/context.d.ts +11 -0
- package/dist/lib/grammar/validators/context.d.ts.map +1 -0
- package/dist/lib/grammar/validators/context.js +5 -0
- package/dist/lib/grammar/validators/context.js.map +1 -0
- package/dist/lib/grammar/validators/derivable.d.ts +63 -0
- package/dist/lib/grammar/validators/derivable.d.ts.map +1 -0
- package/dist/lib/grammar/validators/derivable.js +502 -0
- package/dist/lib/grammar/validators/derivable.js.map +1 -0
- package/dist/lib/grammar/validators/evaluable.d.ts +48 -0
- package/dist/lib/grammar/validators/evaluable.d.ts.map +1 -0
- package/dist/lib/grammar/validators/evaluable.js +226 -0
- package/dist/lib/grammar/validators/evaluable.js.map +1 -0
- package/dist/lib/grammar/validators/presentable.d.ts +45 -0
- package/dist/lib/grammar/validators/presentable.d.ts.map +1 -0
- package/dist/lib/grammar/validators/presentable.js +231 -0
- package/dist/lib/grammar/validators/presentable.js.map +1 -0
- package/dist/lib/grammar/validators/structural.d.ts +103 -0
- package/dist/lib/grammar/validators/structural.d.ts.map +1 -0
- package/dist/lib/grammar/validators/structural.js +602 -0
- package/dist/lib/grammar/validators/structural.js.map +1 -0
- package/dist/lib/index.d.ts +4 -3
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/parsing/argument-parser.d.ts.map +1 -1
- package/dist/lib/parsing/argument-parser.js +52 -10
- package/dist/lib/parsing/argument-parser.js.map +1 -1
- package/dist/lib/types/evaluation.d.ts +1 -1
- package/dist/lib/types/evaluation.d.ts.map +1 -1
- package/dist/lib/types/fork.d.ts +12 -3
- package/dist/lib/types/fork.d.ts.map +1 -1
- package/dist/lib/types/validation.d.ts +0 -6
- package/dist/lib/types/validation.d.ts.map +1 -1
- package/dist/lib/types/validation.js +23 -6
- package/dist/lib/types/validation.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/core/managed-derivation-premise-engine.d.ts +0 -172
- package/dist/lib/core/managed-derivation-premise-engine.d.ts.map +0 -1
- package/dist/lib/core/managed-derivation-premise-engine.js +0 -550
- package/dist/lib/core/managed-derivation-premise-engine.js.map +0 -1
- package/dist/lib/types/grammar.d.ts +0 -83
- package/dist/lib/types/grammar.d.ts.map +0 -1
- package/dist/lib/types/grammar.js +0 -24
- package/dist/lib/types/grammar.js.map +0 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// C6: populateFromCitations / populateFromAxioms factory pattern.
|
|
2
|
+
//
|
|
3
|
+
// Per briefing §7 (post-handoff refinement, 2026-05-14):
|
|
4
|
+
// - Each method is a factory operating on naked-Q derivation premises.
|
|
5
|
+
// - For 0 connections: no-op (naked-Q stays).
|
|
6
|
+
// - For 1 connection: IMPLIES(supporting-var, Q).
|
|
7
|
+
// - For ≥2 connections: IMPLIES(OR(s1, …, sn), Q). In assistive mode
|
|
8
|
+
// a formula buffer is inserted between IMPLIES and OR by the
|
|
9
|
+
// post-build `engine.normalize()` call (AN-1); in permissive mode
|
|
10
|
+
// the OR sits directly under IMPLIES (Structural-valid, but a
|
|
11
|
+
// P-1 violation surfaces via validate('presentable')).
|
|
12
|
+
// - If the target derivation premise is already populated (non-naked-Q),
|
|
13
|
+
// factory returns kind='no-op' without mutating — preserves Proposit's
|
|
14
|
+
// no-changes-without-consent principle AND the Structural-only
|
|
15
|
+
// mutation throw rule. UI/caller is responsible for clearing the
|
|
16
|
+
// antecedent (via a repair primitive) before re-calling.
|
|
17
|
+
// - If no derivation premise exists for derivedClaimId: throws (entity-
|
|
18
|
+
// not-found is a legitimate Structural integrity check).
|
|
19
|
+
//
|
|
20
|
+
// **D2b — permissive-build + explicit normalize() pattern.** The
|
|
21
|
+
// expression-tree build is incremental (`removeExpression(nakedRoot)`
|
|
22
|
+
// → `addExpression(IMPLIES)` → antecedent children → consequent Q).
|
|
23
|
+
// Under the post-mutation AN hook (assistive mode), AN-3 would
|
|
24
|
+
// eagerly collapse 0-child operators between addExpression calls —
|
|
25
|
+
// e.g., after `addExpression(IMPLIES, parent=null)` the IMPLIES has
|
|
26
|
+
// zero children and AN-3 deletes it, so the next addExpression
|
|
27
|
+
// trying to add a child of IMPLIES throws "Parent does not exist".
|
|
28
|
+
// To avoid this, the factory switches to `permissive` for the build
|
|
29
|
+
// and runs a single explicit `engine.normalize()` at the end (only
|
|
30
|
+
// when the caller was originally in assistive mode). This is the
|
|
31
|
+
// canonical incremental-builder pattern for the v1.0 grammar model.
|
|
32
|
+
//
|
|
33
|
+
// **Atomicity contract.** The factory is observed-atomic: callers
|
|
34
|
+
// never see a half-populated tree. The expression-tree replacement
|
|
35
|
+
// proceeds as `removeExpression(nakedRoot)` followed by sequential
|
|
36
|
+
// `addExpression` calls for the populated IMPLIES/OR/var skeleton. All
|
|
37
|
+
// mutations are bundled inside a single synchronous call frame; no
|
|
38
|
+
// reactive listener fires between them on the post-mutation state, and
|
|
39
|
+
// no other engine method runs concurrently (JS is single-threaded).
|
|
40
|
+
// External observers only ever see the pre-call naked-Q state or the
|
|
41
|
+
// fully populated post-call state. The intermediate "tree empty" /
|
|
42
|
+
// "tree partially built" states exist transiently in memory but are
|
|
43
|
+
// never observable from outside `populateFromGrounding`'s call frame.
|
|
44
|
+
//
|
|
45
|
+
// Return shape:
|
|
46
|
+
// { kind: 'populated' | 'no-op',
|
|
47
|
+
// state: TCoreDerivationPremise,
|
|
48
|
+
// resolved?: readonly TViolation[] }
|
|
49
|
+
import { isNakedQTree } from "./naked-q.js";
|
|
50
|
+
/**
|
|
51
|
+
* Run the factory for one grounding kind. Shared by
|
|
52
|
+
* `populateFromCitations` / `populateFromAxioms` — the only difference
|
|
53
|
+
* between them is which lookup is queried.
|
|
54
|
+
*
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
*/
|
|
57
|
+
export function populateFromGrounding(engine, derivedClaimId, lookup) {
|
|
58
|
+
const pe = findDerivationPremiseForClaim(engine, derivedClaimId);
|
|
59
|
+
if (pe === undefined) {
|
|
60
|
+
throw new Error(`populateFrom: no derivation premise found for derivedClaimId "${derivedClaimId}".`);
|
|
61
|
+
}
|
|
62
|
+
// Naked-Q precondition: the premise's expression tree must be a
|
|
63
|
+
// single variable expression at the root. Any other shape (already
|
|
64
|
+
// populated, or some other malformed state) → no-op + return the
|
|
65
|
+
// existing premise data. The premise's `type === 'derivation'` is
|
|
66
|
+
// already guaranteed by `findDerivationPremiseForClaim`, so the
|
|
67
|
+
// tree-shape-only `isNakedQTree` is the correct predicate here.
|
|
68
|
+
if (!isNakedQTree(pe)) {
|
|
69
|
+
return {
|
|
70
|
+
kind: "no-op",
|
|
71
|
+
state: pe.toPremiseData(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Collect unique supporting claim ids in source order. Connection
|
|
75
|
+
// duplicates (same supportingClaimId appearing twice) collapse to
|
|
76
|
+
// one OR child each.
|
|
77
|
+
const connections = lookup.getConnectionsForClaim(derivedClaimId);
|
|
78
|
+
const seen = new Set();
|
|
79
|
+
const supportingIds = [];
|
|
80
|
+
for (const c of connections) {
|
|
81
|
+
if (seen.has(c.supportingClaimId))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(c.supportingClaimId);
|
|
84
|
+
supportingIds.push(c.supportingClaimId);
|
|
85
|
+
}
|
|
86
|
+
if (supportingIds.length === 0) {
|
|
87
|
+
// No supports → nothing to build. Naked-Q stays.
|
|
88
|
+
return {
|
|
89
|
+
kind: "no-op",
|
|
90
|
+
state: pe.toPremiseData(),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Materialize claim-bound variables for each supporting claim. The
|
|
94
|
+
// engine's `ensureClaimBoundVariable` is idempotent and resolves the
|
|
95
|
+
// current claim version from the claim library; if any of these
|
|
96
|
+
// throws CLAIM_NOT_FOUND, propagate (the caller passed a stale
|
|
97
|
+
// lookup pointing at claims that aren't in the engine's library).
|
|
98
|
+
const supportingVars = supportingIds.map((id) => engine.ensureClaimBoundVariable(id));
|
|
99
|
+
// Capture the current Q-root expression id so we can replace it
|
|
100
|
+
// atomically. After this point, mutations on `pe` rebuild the tree.
|
|
101
|
+
// From this point onward up to the final addExpression call, the
|
|
102
|
+
// tree passes through transient empty / partial states; per the
|
|
103
|
+
// atomicity comment at the top of this file those states are not
|
|
104
|
+
// externally observable.
|
|
105
|
+
const nakedRoot = pe.getRootExpression();
|
|
106
|
+
const qVariableId = nakedRoot.variableId;
|
|
107
|
+
const argId = engine.getArgument().id;
|
|
108
|
+
const argVersion = engine.getArgument().version;
|
|
109
|
+
const premiseId = pe.getId();
|
|
110
|
+
const gen = engine.idGenerator;
|
|
111
|
+
// D2b — permissive-build + explicit normalize() pattern. The
|
|
112
|
+
// incremental tree-build below (`removeExpression(nakedRoot)`,
|
|
113
|
+
// then `addExpression(IMPLIES)`, then antecedent, then Q) passes
|
|
114
|
+
// through transient states where parents have 0 children. Under
|
|
115
|
+
// the post-mutation AN hook (assistive mode), AN-3 would
|
|
116
|
+
// eagerly collapse those 0-child operators between addExpression
|
|
117
|
+
// calls, breaking the build. We disarm AN for the build by
|
|
118
|
+
// switching to permissive, then re-arm + run a single explicit
|
|
119
|
+
// `engine.normalize()` at the end to apply AN-1 (formula buffer
|
|
120
|
+
// between IMPLIES and OR) on the fully-built tree.
|
|
121
|
+
//
|
|
122
|
+
// The saved-behavior capture + try/finally is essential: if a
|
|
123
|
+
// mutation inside the build throws, the engine's behavior is
|
|
124
|
+
// restored to its pre-call value rather than left stuck in
|
|
125
|
+
// permissive mode. The `normalize()` call only runs on the
|
|
126
|
+
// success path (it's inside the try after all mutations
|
|
127
|
+
// succeeded) and only when the engine was originally in
|
|
128
|
+
// assistive mode — permissive callers want the un-normalized
|
|
129
|
+
// form per the populate-from JSDoc.
|
|
130
|
+
const savedBehavior = engine.behavior;
|
|
131
|
+
if (savedBehavior === "assistive") {
|
|
132
|
+
engine.setBehavior("permissive");
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
// Step 1: remove the naked-Q root (cascades nothing — it's a
|
|
136
|
+
// leaf).
|
|
137
|
+
pe.removeExpression(nakedRoot.id, true);
|
|
138
|
+
// Step 2: add IMPLIES at root.
|
|
139
|
+
const impliesId = gen();
|
|
140
|
+
pe.addExpression({
|
|
141
|
+
id: impliesId,
|
|
142
|
+
argumentId: argId,
|
|
143
|
+
argumentVersion: argVersion,
|
|
144
|
+
premiseId,
|
|
145
|
+
type: "operator",
|
|
146
|
+
operator: "implies",
|
|
147
|
+
parentId: null,
|
|
148
|
+
position: 0,
|
|
149
|
+
});
|
|
150
|
+
// Step 3: add the antecedent (position 0) — either a single
|
|
151
|
+
// variable (n=1) or an OR with one child per supporting
|
|
152
|
+
// variable (n≥2). In permissive mode the OR sits directly
|
|
153
|
+
// under IMPLIES; the post-build `normalize()` runs AN-1 to
|
|
154
|
+
// insert the formula buffer when the original behavior was
|
|
155
|
+
// assistive.
|
|
156
|
+
if (supportingVars.length === 1) {
|
|
157
|
+
const sv = supportingVars[0];
|
|
158
|
+
const varExprId = gen();
|
|
159
|
+
pe.addExpression({
|
|
160
|
+
id: varExprId,
|
|
161
|
+
argumentId: argId,
|
|
162
|
+
argumentVersion: argVersion,
|
|
163
|
+
premiseId,
|
|
164
|
+
type: "variable",
|
|
165
|
+
variableId: sv.id,
|
|
166
|
+
parentId: impliesId,
|
|
167
|
+
position: 0,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
const orId = gen();
|
|
172
|
+
pe.addExpression({
|
|
173
|
+
id: orId,
|
|
174
|
+
argumentId: argId,
|
|
175
|
+
argumentVersion: argVersion,
|
|
176
|
+
premiseId,
|
|
177
|
+
type: "operator",
|
|
178
|
+
operator: "or",
|
|
179
|
+
parentId: impliesId,
|
|
180
|
+
position: 0,
|
|
181
|
+
});
|
|
182
|
+
for (let i = 0; i < supportingVars.length; i++) {
|
|
183
|
+
const sv = supportingVars[i];
|
|
184
|
+
const varExprId = gen();
|
|
185
|
+
pe.addExpression({
|
|
186
|
+
id: varExprId,
|
|
187
|
+
argumentId: argId,
|
|
188
|
+
argumentVersion: argVersion,
|
|
189
|
+
premiseId,
|
|
190
|
+
type: "variable",
|
|
191
|
+
variableId: sv.id,
|
|
192
|
+
parentId: orId,
|
|
193
|
+
position: i,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Step 4: add the Q consequent (position 1 of IMPLIES).
|
|
198
|
+
const qExprId = gen();
|
|
199
|
+
pe.addExpression({
|
|
200
|
+
id: qExprId,
|
|
201
|
+
argumentId: argId,
|
|
202
|
+
argumentVersion: argVersion,
|
|
203
|
+
premiseId,
|
|
204
|
+
type: "variable",
|
|
205
|
+
variableId: qVariableId,
|
|
206
|
+
parentId: impliesId,
|
|
207
|
+
position: 1,
|
|
208
|
+
});
|
|
209
|
+
// Step 5: restore the original behavior and (if we switched)
|
|
210
|
+
// run the single explicit normalize() to apply AN-1 on the
|
|
211
|
+
// fully-built tree.
|
|
212
|
+
if (savedBehavior === "assistive") {
|
|
213
|
+
engine.setBehavior(savedBehavior);
|
|
214
|
+
engine.normalize();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
// Restore behavior on failure paths too so the engine is not
|
|
219
|
+
// left stuck in permissive mode after an unexpected mutation
|
|
220
|
+
// throw. The build is not transactional — callers expect the
|
|
221
|
+
// engine state to surface the partial build for diagnosis;
|
|
222
|
+
// only the behavior flag gets restored.
|
|
223
|
+
if (savedBehavior === "assistive") {
|
|
224
|
+
engine.setBehavior(savedBehavior);
|
|
225
|
+
}
|
|
226
|
+
throw e;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
kind: "populated",
|
|
230
|
+
state: pe.toPremiseData(),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Find the (sole) derivation premise in the engine whose
|
|
235
|
+
* `derivedClaimId` matches. Returns `undefined` if none exist. If
|
|
236
|
+
* multiple exist (an E-6 violation), returns the first — the caller's
|
|
237
|
+
* naked-Q check then determines whether the factory acts. (E-6 is
|
|
238
|
+
* resolved separately via `removeDuplicateDerivationPremises`.)
|
|
239
|
+
*/
|
|
240
|
+
function findDerivationPremiseForClaim(engine, derivedClaimId) {
|
|
241
|
+
for (const pe of engine.listPremises()) {
|
|
242
|
+
const data = pe.toPremiseData();
|
|
243
|
+
if (data.type !== "derivation")
|
|
244
|
+
continue;
|
|
245
|
+
if (data.derivedClaimId ===
|
|
246
|
+
derivedClaimId) {
|
|
247
|
+
return pe;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=populate-from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populate-from.js","sourceRoot":"","sources":["../../../src/lib/grammar/populate-from.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,yDAAyD;AACzD,yEAAyE;AACzE,gDAAgD;AAChD,oDAAoD;AACpD,uEAAuE;AACvE,iEAAiE;AACjE,sEAAsE;AACtE,kEAAkE;AAClE,2DAA2D;AAC3D,2EAA2E;AAC3E,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,6DAA6D;AAC7D,0EAA0E;AAC1E,6DAA6D;AAC7D,EAAE;AACF,iEAAiE;AACjE,sEAAsE;AACtE,oEAAoE;AACpE,+DAA+D;AAC/D,mEAAmE;AACnE,oEAAoE;AACpE,+DAA+D;AAC/D,mEAAmE;AACnE,oEAAoE;AACpE,mEAAmE;AACnE,iEAAiE;AACjE,oEAAoE;AACpE,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,mEAAmE;AACnE,uEA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AC;AAED;;;;;;GAMG;AACH,SAAS,6BAA6B,CAOlC,MAA2D,EAC3D,cAAsB;IAEtB,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,EAAE,CAAC,aAAa,EAA6B,CAAA;QAC1D,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;YAAE,SAAQ;QACxC,IACK,IAA0C,CAAC,cAAc;YAC1D,cAAc,EAChB,CAAC;YACC,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ArgumentEngine } from "../core/argument-engine.js";
|
|
2
|
+
import type { TCoreArgument, TCorePremise, TCorePropositionalExpression, TCorePropositionalVariable, TCoreClaim } from "../schemata/index.js";
|
|
3
|
+
import type { TViolation } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve E-3 (variable binding doesn't resolve) by deleting each
|
|
6
|
+
* offending variable. `engine.removeVariable()` cascades: it removes
|
|
7
|
+
* the variable record AND every variable-expression referencing it
|
|
8
|
+
* across all premises, collapsing operator parents as necessary.
|
|
9
|
+
*
|
|
10
|
+
* In `'assistive'` mode, the per-mutation AN post-hook fires after
|
|
11
|
+
* each removeVariable call. In `'permissive'`, no AN runs.
|
|
12
|
+
*
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
export declare function removeUnresolvableVariables<TArg extends TCoreArgument = TCoreArgument, TPremise extends TCorePremise = TCorePremise, TExpr extends TCorePropositionalExpression = TCorePropositionalExpression, TVar extends TCorePropositionalVariable = TCorePropositionalVariable, TClaim extends TCoreClaim = TCoreClaim>(engine: ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>): readonly TViolation[];
|
|
16
|
+
/**
|
|
17
|
+
* Resolve E-1 (and/or with < 2 children) by cleaning up the orphan
|
|
18
|
+
* operators. Delegates to `engine.normalize()`'s AN-3 pass, which
|
|
19
|
+
* deletes empty operators and promotes single-child operators in a
|
|
20
|
+
* non-meaning-changing way. The primitive exists alongside normalize()
|
|
21
|
+
* so the UI can present a focused "Remove N orphan operators" action
|
|
22
|
+
* with a precise return value (which violations it resolved).
|
|
23
|
+
*
|
|
24
|
+
* `engine.normalize()` bypasses `behavior` — even in permissive mode
|
|
25
|
+
* the cleanup runs. This matches the UI flow: the user has already
|
|
26
|
+
* accepted the deletion when they clicked the repair button.
|
|
27
|
+
*
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeOrphanOperators<TArg extends TCoreArgument = TCoreArgument, TPremise extends TCorePremise = TCorePremise, TExpr extends TCorePropositionalExpression = TCorePropositionalExpression, TVar extends TCorePropositionalVariable = TCorePropositionalVariable, TClaim extends TCoreClaim = TCoreClaim>(engine: ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>): readonly TViolation[];
|
|
31
|
+
/**
|
|
32
|
+
* Resolve E-6 (claim has > 1 derivation premise) by keeping one
|
|
33
|
+
* premise per `derivedClaimId` and deleting the others. Strategy
|
|
34
|
+
* controls which premise is kept:
|
|
35
|
+
*
|
|
36
|
+
* - `'keep-first'` (default): keep the premise with the lexicographically
|
|
37
|
+
* smallest id; delete the rest. Deterministic and snapshot-stable.
|
|
38
|
+
* - `'keep-largest-antecedent'`: keep the premise whose antecedent
|
|
39
|
+
* subtree has the most claim-bound variable expressions. Ties are
|
|
40
|
+
* broken by lexicographic id. Useful when the user wants the more
|
|
41
|
+
* informative derivation retained.
|
|
42
|
+
*
|
|
43
|
+
* `engine.removePremise()` cascades: it deletes the premise, its
|
|
44
|
+
* expressions, and any premise-bound variables that reference it.
|
|
45
|
+
*
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
*/
|
|
48
|
+
export declare function removeDuplicateDerivationPremises<TArg extends TCoreArgument = TCoreArgument, TPremise extends TCorePremise = TCorePremise, TExpr extends TCorePropositionalExpression = TCorePropositionalExpression, TVar extends TCorePropositionalVariable = TCorePropositionalVariable, TClaim extends TCoreClaim = TCoreClaim>(engine: ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>, strategy?: "keep-first" | "keep-largest-antecedent"): readonly TViolation[];
|
|
49
|
+
/**
|
|
50
|
+
* Resolve D-3 (mixed-grounding antecedent: axioms + citations in one
|
|
51
|
+
* derivation premise) by deleting every axiom-bound variable expression
|
|
52
|
+
* from the antecedent subtree, leaving citations behind. Mirrors the
|
|
53
|
+
* v1.0 migration repair (spec §9.2) for runtime use when an
|
|
54
|
+
* advanced-mode user reaches a mixed state in a permissive engine.
|
|
55
|
+
*
|
|
56
|
+
* In `'assistive'` mode, the per-mutation AN post-hook runs after each
|
|
57
|
+
* expression removal, which may collapse the resulting OR (AN-3) if
|
|
58
|
+
* fewer than two siblings remain after the deletes. In `'permissive'`
|
|
59
|
+
* the OR may end up with a single child (an E-1 / D-2 violation —
|
|
60
|
+
* follow up with `removeOrphanOperators()` if desired).
|
|
61
|
+
*
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
export declare function dropAxiomsFromMixedAntecedent<TArg extends TCoreArgument = TCoreArgument, TPremise extends TCorePremise = TCorePremise, TExpr extends TCorePropositionalExpression = TCorePropositionalExpression, TVar extends TCorePropositionalVariable = TCorePropositionalVariable, TClaim extends TCoreClaim = TCoreClaim>(engine: ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>): readonly TViolation[];
|
|
65
|
+
//# sourceMappingURL=repair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair.d.ts","sourceRoot":"","sources":["../../../src/lib/grammar/repair.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EACR,aAAa,EACb,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC1B,UAAU,EACb,MAAM,sBAAsB,CAAA;AAE7B,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AA6B,CACzC,IAAI,SAAS,aAAa,GAAG,aAAa,EAC1C,QAAQ,SAAS,YAAY,GAAG,YAAY,EAC5C,KAAK,SAAS,4BAA4B,GAAG,4BAA4B,EACzE,IAAI,SAAS,0BAA0B,GAAG,0BAA0B,EACpE,MAAM,SAAS,UAAU,GAAG,UAAU,EAEtC,MAAM,EAAE,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,GAC5D,SAAS,UAAU,EAAE,CA4DvB"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Targeted repair primitives per spec §7.
|
|
2
|
+
//
|
|
3
|
+
// Each primitive is a **user-initiated** destructive fix for a specific
|
|
4
|
+
// Evaluable or Derivable violation that `normalize()` cannot resolve
|
|
5
|
+
// (because resolution would change argument meaning — deleting a
|
|
6
|
+
// variable, dropping a claim reference, removing a duplicate premise).
|
|
7
|
+
//
|
|
8
|
+
// All primitives:
|
|
9
|
+
// - Discover violations via `engine.validate(tier)` filtered by code.
|
|
10
|
+
// - Apply the repair via the engine's structural mutation primitives.
|
|
11
|
+
// - **Respect `engine.behavior`** — AN runs after each mutation in
|
|
12
|
+
// `'assistive'` mode (via the mutation's own post-hook), doesn't run
|
|
13
|
+
// in `'permissive'` mode.
|
|
14
|
+
// - Return the violations they resolved (for UX confirmation / undo
|
|
15
|
+
// messaging / "we made these N changes" feedback).
|
|
16
|
+
//
|
|
17
|
+
// Primitives never auto-run. The UI invokes them only after the user
|
|
18
|
+
// has explicitly accepted the destructive fix.
|
|
19
|
+
import { isClaimBound } from "../schemata/index.js";
|
|
20
|
+
/**
|
|
21
|
+
* Resolve E-3 (variable binding doesn't resolve) by deleting each
|
|
22
|
+
* offending variable. `engine.removeVariable()` cascades: it removes
|
|
23
|
+
* the variable record AND every variable-expression referencing it
|
|
24
|
+
* across all premises, collapsing operator parents as necessary.
|
|
25
|
+
*
|
|
26
|
+
* In `'assistive'` mode, the per-mutation AN post-hook fires after
|
|
27
|
+
* each removeVariable call. In `'permissive'`, no AN runs.
|
|
28
|
+
*
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
*/
|
|
31
|
+
export function removeUnresolvableVariables(engine) {
|
|
32
|
+
const violations = engine
|
|
33
|
+
.validate("evaluable")
|
|
34
|
+
.filter((v) => v.code === "E-3");
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
for (const v of violations) {
|
|
37
|
+
const variableId = v.variableId;
|
|
38
|
+
if (typeof variableId !== "string")
|
|
39
|
+
continue;
|
|
40
|
+
if (seen.has(variableId))
|
|
41
|
+
continue;
|
|
42
|
+
seen.add(variableId);
|
|
43
|
+
engine.removeVariable(variableId);
|
|
44
|
+
}
|
|
45
|
+
return violations;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolve E-1 (and/or with < 2 children) by cleaning up the orphan
|
|
49
|
+
* operators. Delegates to `engine.normalize()`'s AN-3 pass, which
|
|
50
|
+
* deletes empty operators and promotes single-child operators in a
|
|
51
|
+
* non-meaning-changing way. The primitive exists alongside normalize()
|
|
52
|
+
* so the UI can present a focused "Remove N orphan operators" action
|
|
53
|
+
* with a precise return value (which violations it resolved).
|
|
54
|
+
*
|
|
55
|
+
* `engine.normalize()` bypasses `behavior` — even in permissive mode
|
|
56
|
+
* the cleanup runs. This matches the UI flow: the user has already
|
|
57
|
+
* accepted the deletion when they clicked the repair button.
|
|
58
|
+
*
|
|
59
|
+
* @since 1.0.0
|
|
60
|
+
*/
|
|
61
|
+
export function removeOrphanOperators(engine) {
|
|
62
|
+
const violations = engine
|
|
63
|
+
.validate("evaluable")
|
|
64
|
+
.filter((v) => v.code === "E-1");
|
|
65
|
+
if (violations.length === 0)
|
|
66
|
+
return violations;
|
|
67
|
+
engine.normalize();
|
|
68
|
+
return violations;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolve E-6 (claim has > 1 derivation premise) by keeping one
|
|
72
|
+
* premise per `derivedClaimId` and deleting the others. Strategy
|
|
73
|
+
* controls which premise is kept:
|
|
74
|
+
*
|
|
75
|
+
* - `'keep-first'` (default): keep the premise with the lexicographically
|
|
76
|
+
* smallest id; delete the rest. Deterministic and snapshot-stable.
|
|
77
|
+
* - `'keep-largest-antecedent'`: keep the premise whose antecedent
|
|
78
|
+
* subtree has the most claim-bound variable expressions. Ties are
|
|
79
|
+
* broken by lexicographic id. Useful when the user wants the more
|
|
80
|
+
* informative derivation retained.
|
|
81
|
+
*
|
|
82
|
+
* `engine.removePremise()` cascades: it deletes the premise, its
|
|
83
|
+
* expressions, and any premise-bound variables that reference it.
|
|
84
|
+
*
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
*/
|
|
87
|
+
export function removeDuplicateDerivationPremises(engine, strategy = "keep-first") {
|
|
88
|
+
const violations = engine
|
|
89
|
+
.validate("evaluable")
|
|
90
|
+
.filter((v) => v.code === "E-6");
|
|
91
|
+
if (violations.length === 0)
|
|
92
|
+
return violations;
|
|
93
|
+
// E-6 reports every member of a >1-group; collect distinct premise
|
|
94
|
+
// ids per claimId.
|
|
95
|
+
const byClaim = new Map();
|
|
96
|
+
for (const v of violations) {
|
|
97
|
+
const claimId = v.claimId;
|
|
98
|
+
const premiseId = v.premiseId;
|
|
99
|
+
if (typeof claimId !== "string" || typeof premiseId !== "string") {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const set = byClaim.get(claimId) ?? new Set();
|
|
103
|
+
set.add(premiseId);
|
|
104
|
+
byClaim.set(claimId, set);
|
|
105
|
+
}
|
|
106
|
+
for (const [, premiseIdSet] of byClaim) {
|
|
107
|
+
const premiseIds = [...premiseIdSet];
|
|
108
|
+
let keep;
|
|
109
|
+
if (strategy === "keep-largest-antecedent") {
|
|
110
|
+
keep = pickLargestAntecedent(engine, premiseIds);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
keep = [...premiseIds].sort()[0];
|
|
114
|
+
}
|
|
115
|
+
for (const id of premiseIds) {
|
|
116
|
+
if (id === keep)
|
|
117
|
+
continue;
|
|
118
|
+
engine.removePremise(id);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return violations;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Resolve D-3 (mixed-grounding antecedent: axioms + citations in one
|
|
125
|
+
* derivation premise) by deleting every axiom-bound variable expression
|
|
126
|
+
* from the antecedent subtree, leaving citations behind. Mirrors the
|
|
127
|
+
* v1.0 migration repair (spec §9.2) for runtime use when an
|
|
128
|
+
* advanced-mode user reaches a mixed state in a permissive engine.
|
|
129
|
+
*
|
|
130
|
+
* In `'assistive'` mode, the per-mutation AN post-hook runs after each
|
|
131
|
+
* expression removal, which may collapse the resulting OR (AN-3) if
|
|
132
|
+
* fewer than two siblings remain after the deletes. In `'permissive'`
|
|
133
|
+
* the OR may end up with a single child (an E-1 / D-2 violation —
|
|
134
|
+
* follow up with `removeOrphanOperators()` if desired).
|
|
135
|
+
*
|
|
136
|
+
* @since 1.0.0
|
|
137
|
+
*/
|
|
138
|
+
export function dropAxiomsFromMixedAntecedent(engine) {
|
|
139
|
+
const violations = engine
|
|
140
|
+
.validate("derivable")
|
|
141
|
+
.filter((v) => v.code === "D-3");
|
|
142
|
+
if (violations.length === 0)
|
|
143
|
+
return violations;
|
|
144
|
+
// For each D-3 violation, walk the offending antecedent subtree
|
|
145
|
+
// and delete every variable expression whose backing claim is
|
|
146
|
+
// axiomatic. Claim type is resolved via the engine's claim library
|
|
147
|
+
// through `engine.getClaim(id, version)`.
|
|
148
|
+
for (const v of violations) {
|
|
149
|
+
const premiseId = v.premiseId;
|
|
150
|
+
const antecedentExprId = v.expressionId;
|
|
151
|
+
if (typeof premiseId !== "string" ||
|
|
152
|
+
typeof antecedentExprId !== "string") {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const pe = engine.listPremises().find((p) => p.getId() === premiseId);
|
|
156
|
+
if (pe === undefined)
|
|
157
|
+
continue;
|
|
158
|
+
const exprs = pe.getExpressions();
|
|
159
|
+
const childMap = new Map();
|
|
160
|
+
for (const e of exprs) {
|
|
161
|
+
if (e.parentId === null)
|
|
162
|
+
continue;
|
|
163
|
+
const list = childMap.get(e.parentId) ?? [];
|
|
164
|
+
list.push(e);
|
|
165
|
+
childMap.set(e.parentId, list);
|
|
166
|
+
}
|
|
167
|
+
// DFS the antecedent subtree; collect variable expressions whose
|
|
168
|
+
// backing claim resolves to type === 'axiomatic'.
|
|
169
|
+
const toRemove = [];
|
|
170
|
+
const stack = [antecedentExprId];
|
|
171
|
+
while (stack.length > 0) {
|
|
172
|
+
const cursor = stack.pop();
|
|
173
|
+
const cursorExpr = exprs.find((e) => e.id === cursor);
|
|
174
|
+
if (cursorExpr?.type === "variable") {
|
|
175
|
+
const variable = engine.getVariable(cursorExpr.variableId);
|
|
176
|
+
if (variable !== undefined && isClaimBound(variable)) {
|
|
177
|
+
const claim = lookupClaim(engine, variable.claimId, variable.claimVersion);
|
|
178
|
+
if (claim?.type === "axiomatic") {
|
|
179
|
+
toRemove.push(cursorExpr.id);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const kids = childMap.get(cursor) ?? [];
|
|
184
|
+
for (const k of kids)
|
|
185
|
+
stack.push(k.id);
|
|
186
|
+
}
|
|
187
|
+
// Delete the axiom-bound variable expressions. Use deleteSubtree
|
|
188
|
+
// = false because a variable expression is a leaf.
|
|
189
|
+
for (const exprId of toRemove) {
|
|
190
|
+
pe.removeExpression(exprId, false);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return violations;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Pick the premise (from `premiseIds`) whose antecedent subtree
|
|
197
|
+
* contains the most claim-bound variable expressions. Ties broken
|
|
198
|
+
* lexicographically by id for determinism.
|
|
199
|
+
*/
|
|
200
|
+
function pickLargestAntecedent(engine, premiseIds) {
|
|
201
|
+
let best;
|
|
202
|
+
let bestSize = -1;
|
|
203
|
+
const sortedIds = [...premiseIds].sort();
|
|
204
|
+
for (const id of sortedIds) {
|
|
205
|
+
const pe = engine.listPremises().find((p) => p.getId() === id);
|
|
206
|
+
if (pe === undefined)
|
|
207
|
+
continue;
|
|
208
|
+
const exprs = pe.getExpressions();
|
|
209
|
+
const root = exprs.find((e) => e.parentId === null);
|
|
210
|
+
let antecedentSize = 0;
|
|
211
|
+
if (root?.type === "operator" &&
|
|
212
|
+
(root.operator === "implies" || root.operator === "iff")) {
|
|
213
|
+
// Count variable expressions whose ancestor chain reaches the
|
|
214
|
+
// position-0 child of the implies/iff root.
|
|
215
|
+
const antecedent = exprs.find((e) => e.parentId === root.id && e.position === 0);
|
|
216
|
+
if (antecedent !== undefined) {
|
|
217
|
+
const stack = [antecedent.id];
|
|
218
|
+
while (stack.length > 0) {
|
|
219
|
+
const cursor = stack.pop();
|
|
220
|
+
const cursorExpr = exprs.find((e) => e.id === cursor);
|
|
221
|
+
if (cursorExpr?.type === "variable") {
|
|
222
|
+
antecedentSize++;
|
|
223
|
+
}
|
|
224
|
+
for (const c of exprs) {
|
|
225
|
+
if (c.parentId === cursor)
|
|
226
|
+
stack.push(c.id);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (antecedentSize > bestSize) {
|
|
232
|
+
bestSize = antecedentSize;
|
|
233
|
+
best = id;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return best ?? sortedIds[0];
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Resolve a claim record by `(id, version)` from the engine's claim
|
|
240
|
+
* library. We piggyback on `engine.validate('evaluable')`'s context
|
|
241
|
+
* construction — which already does this lookup — by walking variables
|
|
242
|
+
* to find one bound to `claimId/claimVersion` and reaching for the
|
|
243
|
+
* resolved claim via the validator-context shape.
|
|
244
|
+
*
|
|
245
|
+
* Simpler approach: a future `engine.getClaim(id, version)` accessor
|
|
246
|
+
* would clean this up. For v1.0 we route through the public surface.
|
|
247
|
+
*/
|
|
248
|
+
function lookupClaim(engine, claimId, claimVersion) {
|
|
249
|
+
return engine.getClaim(claimId, claimVersion);
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair.js","sourceRoot":"","sources":["../../../src/lib/grammar/repair.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,iEAAiE;AACjE,uEAAuE;AACvE,EAAE;AACF,kBAAkB;AAClB,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,wEAAwE;AACxE,6BAA6B;AAC7B,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,qEAAqE;AACrE,+CAA+C;AAU/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGnD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CAOvC,MAA2D;IAE3D,MAAM,UAAU,GAAG,MAAM;SACpB,QAAQ,CAAC,WAAW,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,CAAA;QAC/B,IAAI,OAAO,UAAU,KAAK,QAAQ;YAAE,SAAQ;QAC5C,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAQ;QAClC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACpB,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,UAAU,CAAA;AACrB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAOjC,MAA2D;IAE3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|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
export declare const GrammarTierSchema: Type.TUnion<[Type.TLiteral<"structural">, Type.TLiteral<"evaluable">, Type.TLiteral<"derivable">, Type.TLiteral<"presentable">]>;
|
|
3
|
+
export type TGrammarTier = Static<typeof GrammarTierSchema>;
|
|
4
|
+
export declare const GrammarRuleCodeSchema: Type.TUnion<[Type.TLiteral<"S-1">, Type.TLiteral<"S-2">, Type.TLiteral<"S-3">, Type.TLiteral<"S-4">, Type.TLiteral<"S-5">, Type.TLiteral<"S-6">, Type.TLiteral<"S-7">, Type.TLiteral<"S-8">, Type.TLiteral<"S-9">, Type.TLiteral<"S-10">, Type.TLiteral<"S-11">, Type.TLiteral<"S-12">, Type.TLiteral<"S-13">, Type.TLiteral<"S-14">, Type.TLiteral<"E-1">, Type.TLiteral<"E-3">, Type.TLiteral<"E-4">, Type.TLiteral<"E-5">, Type.TLiteral<"E-6">, Type.TLiteral<"E-7">, Type.TLiteral<"D-1">, Type.TLiteral<"D-2">, Type.TLiteral<"D-3">, Type.TLiteral<"D-4">, Type.TLiteral<"D-5">, Type.TLiteral<"D-6">, Type.TLiteral<"P-1">, Type.TLiteral<"P-2">, Type.TLiteral<"P-3">, Type.TLiteral<"P-4">, Type.TLiteral<"P-5">]>;
|
|
5
|
+
export type TGrammarRuleCode = Static<typeof GrammarRuleCodeSchema>;
|
|
6
|
+
export declare const ViolationSchema: Type.TObject<{
|
|
7
|
+
tier: Type.TUnion<[Type.TLiteral<"structural">, Type.TLiteral<"evaluable">, Type.TLiteral<"derivable">, Type.TLiteral<"presentable">]>;
|
|
8
|
+
code: Type.TUnion<[Type.TLiteral<"S-1">, Type.TLiteral<"S-2">, Type.TLiteral<"S-3">, Type.TLiteral<"S-4">, Type.TLiteral<"S-5">, Type.TLiteral<"S-6">, Type.TLiteral<"S-7">, Type.TLiteral<"S-8">, Type.TLiteral<"S-9">, Type.TLiteral<"S-10">, Type.TLiteral<"S-11">, Type.TLiteral<"S-12">, Type.TLiteral<"S-13">, Type.TLiteral<"S-14">, Type.TLiteral<"E-1">, Type.TLiteral<"E-3">, Type.TLiteral<"E-4">, Type.TLiteral<"E-5">, Type.TLiteral<"E-6">, Type.TLiteral<"E-7">, Type.TLiteral<"D-1">, Type.TLiteral<"D-2">, Type.TLiteral<"D-3">, Type.TLiteral<"D-4">, Type.TLiteral<"D-5">, Type.TLiteral<"D-6">, Type.TLiteral<"P-1">, Type.TLiteral<"P-2">, Type.TLiteral<"P-3">, Type.TLiteral<"P-4">, Type.TLiteral<"P-5">]>;
|
|
9
|
+
message: Type.TString;
|
|
10
|
+
argumentId: Type.TOptional<Type.TString>;
|
|
11
|
+
premiseId: Type.TOptional<Type.TString>;
|
|
12
|
+
expressionId: Type.TOptional<Type.TString>;
|
|
13
|
+
variableId: Type.TOptional<Type.TString>;
|
|
14
|
+
claimId: Type.TOptional<Type.TString>;
|
|
15
|
+
}>;
|
|
16
|
+
export type TViolation = Static<typeof ViolationSchema>;
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/grammar/types.ts"],"names":[],"mappings":"AAmBA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AAI3C,eAAO,MAAM,iBAAiB,kIAK5B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAI3D,eAAO,MAAM,qBAAqB,8rBAoChC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAUnE,eAAO,MAAM,eAAe;;;;;;;;;EAY3B,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAA"}
|