@turingcode/cli 0.1.1 → 0.2.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 +96 -0
- package/dist/cli/create-cli.js +7 -1
- package/dist/core/bound-error.js +14 -0
- package/dist/{features/table/ast.js → core/exact/expression.js} +22 -14
- package/dist/{features/table → core/exact}/fraction.js +62 -0
- package/dist/core/files.js +26 -0
- package/dist/{features/table/shape.js → core/json-shape.js} +45 -40
- package/dist/core/report.js +14 -0
- package/dist/core/tables/csv.js +95 -0
- package/dist/core/tables/markdown.js +107 -0
- package/dist/core/tables/types.js +1 -0
- package/dist/features/contract/check.js +31 -0
- package/dist/features/contract/command.js +60 -0
- package/dist/features/contract/describe.js +93 -0
- package/dist/features/contract/diagnostics.js +108 -0
- package/dist/features/contract/load.js +212 -0
- package/dist/features/contract/model.js +33 -0
- package/dist/features/contract/rules.js +197 -0
- package/dist/features/table/check.js +295 -0
- package/dist/features/table/command.js +22 -75
- package/dist/features/table/read.js +33 -0
- package/package.json +2 -2
- package/dist/features/table/contract.js +0 -487
- package/dist/features/table/contract_check.js +0 -265
- package/dist/features/table/describe.js +0 -200
- package/dist/features/table/diagnostics.js +0 -129
- package/dist/features/table/format.js +0 -75
- package/dist/features/table/primitives.js +0 -268
- package/dist/features/table/source_kinds.js +0 -41
- package/dist/features/table/table_check.js +0 -538
- package/dist/features/table/tables.js +0 -223
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/** Most rows listed on one grouped line before "+N more". */
|
|
2
|
-
const MAX_ROWS_PER_LINE = 20;
|
|
3
|
-
const isNotChecked = (d) => d.code.endsWith(".NOT_CHECKED");
|
|
4
|
-
/** Evidence worth printing: a rule ID, not a generic declaration or spec section. */
|
|
5
|
-
const ruleOf = (d) => (/^(declaration|spec |extensions_policy|Extensions)/.test(d.evidence) ? "" : ` [${d.evidence}]`);
|
|
6
|
-
const place = (...parts) => parts.filter(p => p !== "*" && p !== "-").join(" ");
|
|
7
|
-
/**
|
|
8
|
-
* Renders diagnostics as compact text lines for agents: one line per finding,
|
|
9
|
-
* findings that differ only by row grouped onto one line, rules not checked
|
|
10
|
-
* yet on one line, and each fix hint once per code.
|
|
11
|
-
*
|
|
12
|
-
* @param {Diagnostic[]} diags - Sorted diagnostics.
|
|
13
|
-
* @returns {string[]} The lines.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* formatDiagnostics(result.diagnostics);
|
|
17
|
-
* // ["FAIL C0.BAD_VALUE Facts Class ×2: F-2=Other, F-5=Lim; expected limit, other",
|
|
18
|
-
* // "fix C0.BAD_VALUE: Use one of the allowed values, spelled exactly."]
|
|
19
|
-
*/
|
|
20
|
-
export function formatDiagnostics(diags) {
|
|
21
|
-
const lines = [];
|
|
22
|
-
const groups = new Map();
|
|
23
|
-
for (const d of diags.filter(d => !isNotChecked(d))) {
|
|
24
|
-
const key = [d.severity, d.code, d.table, d.column, d.expected, d.evidence].join("\u0000");
|
|
25
|
-
groups.set(key, [...(groups.get(key) ?? []), d]);
|
|
26
|
-
}
|
|
27
|
-
for (const [d, ...more] of groups.values()) {
|
|
28
|
-
if (!more.length) {
|
|
29
|
-
lines.push(`${d.severity} ${d.code} ${place(d.table, d.row_id, d.column)}: ${d.message}; expected ${d.expected}${ruleOf(d)}`);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const all = [d, ...more];
|
|
33
|
-
const rows = all.slice(0, MAX_ROWS_PER_LINE).map(x => `${x.row_id}=${x.found}`).join(", ");
|
|
34
|
-
const extra = all.length > MAX_ROWS_PER_LINE ? ` +${all.length - MAX_ROWS_PER_LINE} more` : "";
|
|
35
|
-
lines.push(`${d.severity} ${d.code} ${place(d.table, d.column)} ×${all.length}: ${rows}${extra}; expected ${d.expected}${ruleOf(d)}`);
|
|
36
|
-
}
|
|
37
|
-
const notChecked = diags.filter(isNotChecked);
|
|
38
|
-
if (notChecked.length) {
|
|
39
|
-
lines.push(`not checked yet, check by hand: ${notChecked.map(d => `${d.evidence} (${d.found})`).join(", ")}`);
|
|
40
|
-
}
|
|
41
|
-
const hints = new Map(diags.filter(d => !isNotChecked(d) && d.fix_hint).map(d => [d.code, d.fix_hint]));
|
|
42
|
-
for (const [codeName, hint] of hints)
|
|
43
|
-
lines.push(`fix ${codeName}: ${hint}`);
|
|
44
|
-
return lines;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Compact text for a table_check result.
|
|
48
|
-
*
|
|
49
|
-
* @param {TableCheckResult} r - The result.
|
|
50
|
-
* @returns {string} Status line, then the diagnostics.
|
|
51
|
-
*/
|
|
52
|
-
export function formatTableCheck(r) {
|
|
53
|
-
const s = r.summary;
|
|
54
|
-
const pin = r.contract ? `${r.contract.contract_id}@${r.contract.version}` : "-";
|
|
55
|
-
const notes = r.diagnostics.filter(d => d.severity === "NOTE" && !isNotChecked(d)).length;
|
|
56
|
-
const head = `${r.status} ${pin}: ${s.tables_checked} tables, ${s.rows_checked} rows, ${s.fail_count} FAIL`
|
|
57
|
-
+ (notes ? `, ${notes} NOTE` : "");
|
|
58
|
-
return [head, ...formatDiagnostics(r.diagnostics)].join("\n") + "\n";
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Compact text for a contract_check result (also used for contract_describe errors).
|
|
62
|
-
*
|
|
63
|
-
* @param {ContractCheckResult} r - The result.
|
|
64
|
-
* @returns {string} Status line, cross-stage edges, then the diagnostics.
|
|
65
|
-
*/
|
|
66
|
-
export function formatContractCheck(r) {
|
|
67
|
-
const pin = r.contract_id ? `${r.contract_id}@${r.version}` : "-";
|
|
68
|
-
const fails = r.diagnostics.filter(d => d.severity === "FAIL").length;
|
|
69
|
-
const checked = r.checked_contracts ? `${r.checked_contracts.length} contract(s), ` : "";
|
|
70
|
-
return [
|
|
71
|
-
`${r.status} ${pin}: ${checked}${fails} FAIL`,
|
|
72
|
-
...(r.graph_edges ?? []).map(e => `edge ${e.from_contract} ${e.table}.${e.column} -> ${e.to_contract} ${e.target_table}`),
|
|
73
|
-
...formatDiagnostics(r.diagnostics),
|
|
74
|
-
].join("\n") + "\n";
|
|
75
|
-
}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
const S = "string";
|
|
2
|
-
const SL = { list: "string" };
|
|
3
|
-
const B = "bool";
|
|
4
|
-
const I = "int";
|
|
5
|
-
const WHEN = { map: "string_or_list" };
|
|
6
|
-
/**
|
|
7
|
-
* The closed catalog of rule primitives with their normative params
|
|
8
|
-
* signatures (spec §3.3, "Normative params Signatures"). Names, including
|
|
9
|
-
* their spelling, are copied from the spec.
|
|
10
|
-
*/
|
|
11
|
-
export const PRIMITIVES = {
|
|
12
|
-
required_tables: { group: "C0", params: { "extensions_table?": S } },
|
|
13
|
-
column_order: { group: "C0", params: { "allow_extensions?": B, "extensions_table?": S } },
|
|
14
|
-
id_pattern: { group: "C0", params: { id_col: S, pattern: "regex" } },
|
|
15
|
-
unique_id: { group: "C0", params: { id_col: S } },
|
|
16
|
-
allowed_values: { group: "C0", params: { column: S, values: SL, "allow_dash?": B, "multi_valued_sep?": S } },
|
|
17
|
-
non_empty: { group: "C0", params: { columns: SL } },
|
|
18
|
-
conditional_non_dash: { group: "C0", params: { when_column: S, in: SL, target_column: S, "when?": WHEN } },
|
|
19
|
-
sentinel_row: { group: "C0", params: { id_col: S, id_value: S, min_count: I, max_count: I } },
|
|
20
|
-
extension_schema: { group: "C0", params: { "extensions_table?": S } },
|
|
21
|
-
foreign_key: {
|
|
22
|
-
group: "C1",
|
|
23
|
-
params: { column: S, "target_table?": S, "target_column?": S, "target_contracts?": SL, "allow_dash?": B },
|
|
24
|
-
},
|
|
25
|
-
scoped_id_trace: {
|
|
26
|
-
group: "C1",
|
|
27
|
-
params: {
|
|
28
|
-
mode: { enum: ["stage0_definition_coverage", "stage1_requirements_scope", "table_to_table_trace"] },
|
|
29
|
-
"source_col?": S, "target_table?": S, "target_col?": S,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
version_locked_anchor: {
|
|
33
|
-
group: "C1",
|
|
34
|
-
params: { upstream_stage: S, check_stage0_anchor: B, check_claimed_values: B, "check_q_numbers?": B, "skip_tables?": SL },
|
|
35
|
-
},
|
|
36
|
-
extension_reader_citation: {
|
|
37
|
-
group: "C1", params: { upstream_stages: SL, "exclude_sections?": SL, "allow_row_id_for_column?": B },
|
|
38
|
-
},
|
|
39
|
-
quote_on_line: {
|
|
40
|
-
group: "C2",
|
|
41
|
-
params: {
|
|
42
|
-
call_col: S, quote_col: S, "doc_col?": S, "page_col?": S, "line_col?": S, "value_col?": S, "unit_col?": S,
|
|
43
|
-
"max_words?": I, "strip_stage_prefix?": B, "when?": WHEN,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
token_whole_in_quote: {
|
|
47
|
-
group: "C2", params: { target_col: S, quote_col: S, "forbid_quote_equals_value?": B, "when?": WHEN },
|
|
48
|
-
},
|
|
49
|
-
token_provenance: {
|
|
50
|
-
group: "C2",
|
|
51
|
-
params: {
|
|
52
|
-
target_col: S, quote_col: S, value_col: S, call_col: S, "include_table_header?": B,
|
|
53
|
-
"strip_stage_names?": B, "strip_id_tokens?": B, "when?": WHEN,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
definition_sentence_coverage: {
|
|
57
|
-
group: "C2",
|
|
58
|
-
params: {
|
|
59
|
-
req_table: S, req_line_col: S, req_quote_col: S, qty_table: S, qty_line_col: S, qty_written_col: S,
|
|
60
|
-
qty_tol_col: S, not_qty_table: S, not_qty_line_col: S, not_qty_token_col: S,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
page_span_coverage: {
|
|
64
|
-
group: "C2",
|
|
65
|
-
params: {
|
|
66
|
-
calls_table: S, "lists_table?": S, "file_col?": S, "total_rows_col?": S, "call_ids_col?": S,
|
|
67
|
-
"parts_table?": S, "facts_table?": S, "fact_call_col?": S, "source_kind_ids?": SL,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
harvest_reply_rows: {
|
|
71
|
-
group: "C2", params: { target_table: S, target_col: S, lists_table: S, calls_table: S, "ref_set_name?": S },
|
|
72
|
-
},
|
|
73
|
-
concept_method_mapping_coverage: { group: "C2", params: { concepts_table: S, methods_Col: S, stage2_Ref_Col: S } },
|
|
74
|
-
Cross_Column_Predicate: {
|
|
75
|
-
group: "C2",
|
|
76
|
-
params: {
|
|
77
|
-
when: { obj: { col: S, op: { enum: ["eq", "ne", "in", "not_in", "empty", "non_empty"] }, "val?": "any" } },
|
|
78
|
-
then: { list: { obj: { col: S, op: S, "val?": "any" } } },
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
json_arg_schema: {
|
|
82
|
-
group: "C2",
|
|
83
|
-
params: {
|
|
84
|
-
args_col: S, "tool_col?": S, "forbid_helper_path?": B,
|
|
85
|
-
"doc_kind_rules?": { list: { obj: { tool: S, doc_kind: S } } },
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
conditional_source_rule: {
|
|
89
|
-
group: "C2",
|
|
90
|
-
params: {
|
|
91
|
-
kind_column: S, extracted_value: S, premise_value: S, call_column: S, calls_table: S, quote_column: S,
|
|
92
|
-
doc_kind_column: S, basis_column: S, premise_target_table: S, "tool_doc_kind_map?": { map: S },
|
|
93
|
-
"forbidden_substrings?": SL, "calc_column?": S, "documented_value?": S, "factor_value?": S, "author_value?": S,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
source_priority_order: {
|
|
97
|
-
group: "C2", params: { facts_list_col: S, chosen_col: S, "reason_col?": S, facts_table: S, doc_kind_col: S },
|
|
98
|
-
},
|
|
99
|
-
ordered_range: { group: "C2", params: { min_col: S, "typ_col?": S, max_col: S, "allow_na?": B } },
|
|
100
|
-
unit_in_quote: { group: "C3", params: { unit_col: S, quote_col: S, "when?": WHEN } },
|
|
101
|
-
unit_missing_in_quote: { group: "C3", params: { value_cols: SL, unit_col: S, quote_col: S, "when?": WHEN } },
|
|
102
|
-
unit_convert_or_factor: {
|
|
103
|
-
group: "C3",
|
|
104
|
-
params: {
|
|
105
|
-
expr_col: S, "unit_col?": S, calls_table: S, "refs_col?": S, "rel_tol?": S,
|
|
106
|
-
"require_as_factor?": B, "note_if_no_call?": B,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
tolerance_bounds: {
|
|
110
|
-
group: "C3",
|
|
111
|
-
params: { value_col: S, tolerance_col: S, lower_col: S, upper_col: S, bound_type_col: S, unit_col: S },
|
|
112
|
-
},
|
|
113
|
-
register_layout_and_decode: {
|
|
114
|
-
group: "C3",
|
|
115
|
-
params: { registers_table: S, fields_table: S, "ops_table?": S, calls_table: S, "mcu_exclude_table?": S },
|
|
116
|
-
},
|
|
117
|
-
unit_spelling: { group: "C3", params: null },
|
|
118
|
-
value_requires_unit: { group: "C3", params: null },
|
|
119
|
-
calc_fraction_eval: {
|
|
120
|
-
group: "C4",
|
|
121
|
-
params: {
|
|
122
|
-
calc_col: S, value_col: S, "unit_col?": S, ref_tables: SL, "refs_col?": S,
|
|
123
|
-
"mode?": { enum: ["calc_body", "frame_calc", "author_timing"] },
|
|
124
|
-
"forbid_id_in_exponent?": B, "require_unit_convert_call?": B,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
math_calculate_verify: {
|
|
128
|
-
group: "C4", params: { expr_col: S, result_col: S, calls_table: S, "q_id_col?": S, "f_ids_col?": S },
|
|
129
|
-
},
|
|
130
|
-
written_equals: { group: "C4", params: { expr_col: S, written_col: S, "min_sig_digits?": I } },
|
|
131
|
-
margin_sign_agrees: { group: "C4", params: { result_col: S, verdict_col: S } },
|
|
132
|
-
oracle_eval_and_vectors: {
|
|
133
|
-
group: "C4",
|
|
134
|
-
params: {
|
|
135
|
-
variables_table: S, formulas_table: S, methods_table: S, arguments_table: S,
|
|
136
|
-
output_fields_table: S, line_grammar_table: S, vectors_table: S,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
line_grammar_and_width: {
|
|
140
|
-
group: "C4", params: { output_fields_table: S, line_grammar_table: S, variables_table: S, formulas_table: S },
|
|
141
|
-
},
|
|
142
|
-
custom_predicate: { group: "C4", params: { hook_name: S, max_rule_fraction: { literal: "0.10" } } },
|
|
143
|
-
acceptance_and_claim_provenance: {
|
|
144
|
-
group: "C5",
|
|
145
|
-
params: {
|
|
146
|
-
requirements_table: S, "scenarios_table?": S, questions_table: S,
|
|
147
|
-
upstream_quantities_table: S, "upstream_reqs_table?": S,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
checklist_floor: {
|
|
151
|
-
group: "C5",
|
|
152
|
-
params: { checklist_csv: S, due_stage: I, coverage_table: S, item_col: S, status_col: S, evidence_col: S },
|
|
153
|
-
},
|
|
154
|
-
no_device_bound_guard: {
|
|
155
|
-
group: "C5", params: { feasibility_table: S, verdict_col: S, margin_col: S, facts_table: S },
|
|
156
|
-
},
|
|
157
|
-
owner_item_closing: {
|
|
158
|
-
group: "C5", params: { closings_table: S, item_col: S, owner_stage: I, calls_table: S, facts_table: S },
|
|
159
|
-
},
|
|
160
|
-
free_text_token_provenance: {
|
|
161
|
-
group: "C5",
|
|
162
|
-
params: {
|
|
163
|
-
target_cols: SL, refs_col: S, "mode?": { enum: ["all_numbers", "hex_only", "whole_or_number"] },
|
|
164
|
-
"allow_small_ints?": { list: I },
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
output_replacement_guard: { group: "C5", params: { named_by_col: S, definition_file: S, upstream_reqs_table: S } },
|
|
168
|
-
state_machine_exits: {
|
|
169
|
-
group: "C5", params: { conditions_table: S, behaviour_table: S, error_table: S, line_grammar_table: S },
|
|
170
|
-
},
|
|
171
|
-
critic_round_present: {
|
|
172
|
-
group: "C5", params: { critic_table: S, reply_file_pattern: S, point_col: S, status_col: S, reason_col: S },
|
|
173
|
-
},
|
|
174
|
-
card_prose_conformance: { group: "C5", params: { card_glob: S, forbidden_Import_Tokens: SL } },
|
|
175
|
-
helper_file_cap: {
|
|
176
|
-
group: "C5", params: { max_files: I, dir: S, problems_table: S, detected_col: S, row_prefix: S },
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
/** Primitives that need `contract.unit_table` (C3 unit rules, spec §3.1). */
|
|
180
|
-
export const NEEDS_UNIT_TABLE = new Set([
|
|
181
|
-
"unit_in_quote", "unit_missing_in_quote", "unit_convert_or_factor", "tolerance_bounds", "unit_spelling",
|
|
182
|
-
"value_requires_unit",
|
|
183
|
-
]);
|
|
184
|
-
/** Primitives that need `contract.source_order` (K5 priority, spec §3.1). */
|
|
185
|
-
export const NEEDS_SOURCE_ORDER = new Set(["source_priority_order"]);
|
|
186
|
-
/**
|
|
187
|
-
* What each table/column param of a primitive names, so contract_check can
|
|
188
|
-
* resolve it: `"table"` = a table of this contract; `"self"` = a column of
|
|
189
|
-
* the rule's own table; any other value = a column of the table named by
|
|
190
|
-
* that param. Params not listed (upstream tables, files, CSV aliases, nested
|
|
191
|
-
* objects) are not resolved here; foreign_key has its own check.
|
|
192
|
-
*/
|
|
193
|
-
export const PARAM_REFS = {
|
|
194
|
-
id_pattern: { id_col: "self" },
|
|
195
|
-
unique_id: { id_col: "self" },
|
|
196
|
-
allowed_values: { column: "self" },
|
|
197
|
-
non_empty: { columns: "self" },
|
|
198
|
-
conditional_non_dash: { when_column: "self", target_column: "self" },
|
|
199
|
-
sentinel_row: { id_col: "self" },
|
|
200
|
-
scoped_id_trace: { source_col: "self" },
|
|
201
|
-
quote_on_line: {
|
|
202
|
-
call_col: "self", quote_col: "self", doc_col: "self", page_col: "self", line_col: "self",
|
|
203
|
-
value_col: "self", unit_col: "self",
|
|
204
|
-
},
|
|
205
|
-
token_whole_in_quote: { target_col: "self", quote_col: "self" },
|
|
206
|
-
token_provenance: { target_col: "self", quote_col: "self", value_col: "self", call_col: "self" },
|
|
207
|
-
definition_sentence_coverage: {
|
|
208
|
-
req_table: "table", req_line_col: "req_table", req_quote_col: "req_table",
|
|
209
|
-
qty_table: "table", qty_line_col: "qty_table", qty_written_col: "qty_table", qty_tol_col: "qty_table",
|
|
210
|
-
not_qty_table: "table", not_qty_line_col: "not_qty_table", not_qty_token_col: "not_qty_table",
|
|
211
|
-
},
|
|
212
|
-
page_span_coverage: {
|
|
213
|
-
calls_table: "table", lists_table: "table", file_col: "lists_table", total_rows_col: "lists_table",
|
|
214
|
-
call_ids_col: "lists_table", parts_table: "table", facts_table: "table", fact_call_col: "facts_table",
|
|
215
|
-
},
|
|
216
|
-
harvest_reply_rows: { target_table: "table", target_col: "target_table", lists_table: "table", calls_table: "table" },
|
|
217
|
-
concept_method_mapping_coverage: { concepts_table: "table" },
|
|
218
|
-
json_arg_schema: { args_col: "self", tool_col: "self" },
|
|
219
|
-
conditional_source_rule: {
|
|
220
|
-
kind_column: "self", call_column: "self", quote_column: "self", doc_kind_column: "self", basis_column: "self",
|
|
221
|
-
calc_column: "self", calls_table: "table", premise_target_table: "table",
|
|
222
|
-
},
|
|
223
|
-
source_priority_order: {
|
|
224
|
-
facts_list_col: "self", chosen_col: "self", reason_col: "self", facts_table: "table", doc_kind_col: "facts_table",
|
|
225
|
-
},
|
|
226
|
-
ordered_range: { min_col: "self", typ_col: "self", max_col: "self" },
|
|
227
|
-
unit_in_quote: { unit_col: "self", quote_col: "self" },
|
|
228
|
-
unit_missing_in_quote: { value_cols: "self", unit_col: "self", quote_col: "self" },
|
|
229
|
-
unit_convert_or_factor: { expr_col: "self", unit_col: "self", refs_col: "self", calls_table: "table" },
|
|
230
|
-
tolerance_bounds: {
|
|
231
|
-
value_col: "self", tolerance_col: "self", lower_col: "self", upper_col: "self", bound_type_col: "self",
|
|
232
|
-
unit_col: "self",
|
|
233
|
-
},
|
|
234
|
-
register_layout_and_decode: {
|
|
235
|
-
registers_table: "table", fields_table: "table", ops_table: "table", calls_table: "table",
|
|
236
|
-
mcu_exclude_table: "table",
|
|
237
|
-
},
|
|
238
|
-
calc_fraction_eval: { calc_col: "self", value_col: "self", unit_col: "self", refs_col: "self" },
|
|
239
|
-
math_calculate_verify: {
|
|
240
|
-
expr_col: "self", result_col: "self", q_id_col: "self", f_ids_col: "self", calls_table: "table",
|
|
241
|
-
},
|
|
242
|
-
written_equals: { expr_col: "self", written_col: "self" },
|
|
243
|
-
margin_sign_agrees: { result_col: "self", verdict_col: "self" },
|
|
244
|
-
oracle_eval_and_vectors: {
|
|
245
|
-
variables_table: "table", formulas_table: "table", methods_table: "table", arguments_table: "table",
|
|
246
|
-
output_fields_table: "table", line_grammar_table: "table", vectors_table: "table",
|
|
247
|
-
},
|
|
248
|
-
line_grammar_and_width: {
|
|
249
|
-
output_fields_table: "table", line_grammar_table: "table", variables_table: "table", formulas_table: "table",
|
|
250
|
-
},
|
|
251
|
-
acceptance_and_claim_provenance: { requirements_table: "table", scenarios_table: "table", questions_table: "table" },
|
|
252
|
-
checklist_floor: {
|
|
253
|
-
coverage_table: "table", item_col: "coverage_table", status_col: "coverage_table", evidence_col: "coverage_table",
|
|
254
|
-
},
|
|
255
|
-
no_device_bound_guard: {
|
|
256
|
-
feasibility_table: "table", facts_table: "table", verdict_col: "feasibility_table", margin_col: "feasibility_table",
|
|
257
|
-
},
|
|
258
|
-
owner_item_closing: { closings_table: "table", calls_table: "table", facts_table: "table", item_col: "closings_table" },
|
|
259
|
-
free_text_token_provenance: { target_cols: "self", refs_col: "self" },
|
|
260
|
-
output_replacement_guard: { named_by_col: "self" },
|
|
261
|
-
state_machine_exits: {
|
|
262
|
-
conditions_table: "table", behaviour_table: "table", error_table: "table", line_grammar_table: "table",
|
|
263
|
-
},
|
|
264
|
-
critic_round_present: {
|
|
265
|
-
critic_table: "table", point_col: "critic_table", status_col: "critic_table", reason_col: "critic_table",
|
|
266
|
-
},
|
|
267
|
-
helper_file_cap: { problems_table: "table", detected_col: "problems_table" },
|
|
268
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { contractDiag } from "./diagnostics.js";
|
|
2
|
-
import { checkShape } from "./shape.js";
|
|
3
|
-
const REGISTRY = {
|
|
4
|
-
obj: {
|
|
5
|
-
source_kinds_version: "version",
|
|
6
|
-
kinds: {
|
|
7
|
-
list: {
|
|
8
|
-
obj: {
|
|
9
|
-
kind_id: "string",
|
|
10
|
-
filename_pattern: "string",
|
|
11
|
-
doc_kind: "string",
|
|
12
|
-
trigger_mode: { enum: ["per_extracted_part", "when_page_cited"] },
|
|
13
|
-
read_mode: { enum: ["all_pages", "by_row_id"] },
|
|
14
|
-
populates_ref_set: { nullable: { obj: { ref_set_name: "string", id_column_regex: "regex" } } },
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
min: 1,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Validates a `source_kinds` registry.
|
|
23
|
-
*
|
|
24
|
-
* @param {unknown} data - Parsed registry JSON.
|
|
25
|
-
* @returns {Diagnostic[]} Empty when the registry is valid.
|
|
26
|
-
*/
|
|
27
|
-
export function validateSourceKinds(data) {
|
|
28
|
-
const out = [];
|
|
29
|
-
const at = { table: "source_kinds" };
|
|
30
|
-
if (!checkShape(data, REGISTRY, "$", at, out)) {
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
const seen = new Set();
|
|
34
|
-
for (const kind of data.kinds) {
|
|
35
|
-
if (seen.has(kind.kind_id)) {
|
|
36
|
-
out.push(contractDiag("CONTRACT.DUPLICATE", `duplicate kind_id '${kind.kind_id}'`, at, kind.kind_id, "unique kind_id"));
|
|
37
|
-
}
|
|
38
|
-
seen.add(kind.kind_id);
|
|
39
|
-
}
|
|
40
|
-
return out;
|
|
41
|
-
}
|