dsh-data-quality 0.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 (91) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +201 -0
  3. package/README.es.md +181 -0
  4. package/README.hi.md +181 -0
  5. package/README.md +181 -0
  6. package/README.pt.md +181 -0
  7. package/README.zh.md +181 -0
  8. package/THIRD_PARTY_NOTICES.md +20 -0
  9. package/cordis.patch.yml +46 -0
  10. package/lib/index.js +2458 -0
  11. package/lib/types/clean.d.ts +82 -0
  12. package/lib/types/clean.d.ts.map +1 -0
  13. package/lib/types/clean.js +351 -0
  14. package/lib/types/clean.js.map +1 -0
  15. package/lib/types/config.d.ts +47 -0
  16. package/lib/types/config.d.ts.map +1 -0
  17. package/lib/types/config.js +66 -0
  18. package/lib/types/config.js.map +1 -0
  19. package/lib/types/dataset.d.ts +133 -0
  20. package/lib/types/dataset.d.ts.map +1 -0
  21. package/lib/types/dataset.js +404 -0
  22. package/lib/types/dataset.js.map +1 -0
  23. package/lib/types/events.d.ts +73 -0
  24. package/lib/types/events.d.ts.map +1 -0
  25. package/lib/types/events.js +41 -0
  26. package/lib/types/events.js.map +1 -0
  27. package/lib/types/index.d.ts +45 -0
  28. package/lib/types/index.d.ts.map +1 -0
  29. package/lib/types/index.js +78 -0
  30. package/lib/types/index.js.map +1 -0
  31. package/lib/types/present.d.ts +24 -0
  32. package/lib/types/present.d.ts.map +1 -0
  33. package/lib/types/present.js +34 -0
  34. package/lib/types/present.js.map +1 -0
  35. package/lib/types/profile.d.ts +79 -0
  36. package/lib/types/profile.d.ts.map +1 -0
  37. package/lib/types/profile.js +196 -0
  38. package/lib/types/profile.js.map +1 -0
  39. package/lib/types/provider-local.d.ts +56 -0
  40. package/lib/types/provider-local.d.ts.map +1 -0
  41. package/lib/types/provider-local.js +163 -0
  42. package/lib/types/provider-local.js.map +1 -0
  43. package/lib/types/service.d.ts +160 -0
  44. package/lib/types/service.d.ts.map +1 -0
  45. package/lib/types/service.js +25 -0
  46. package/lib/types/service.js.map +1 -0
  47. package/lib/types/store.d.ts +61 -0
  48. package/lib/types/store.d.ts.map +1 -0
  49. package/lib/types/store.js +42 -0
  50. package/lib/types/store.js.map +1 -0
  51. package/lib/types/tools/clean.d.ts +14 -0
  52. package/lib/types/tools/clean.d.ts.map +1 -0
  53. package/lib/types/tools/clean.js +146 -0
  54. package/lib/types/tools/clean.js.map +1 -0
  55. package/lib/types/tools/profile.d.ts +13 -0
  56. package/lib/types/tools/profile.d.ts.map +1 -0
  57. package/lib/types/tools/profile.js +91 -0
  58. package/lib/types/tools/profile.js.map +1 -0
  59. package/lib/types/tools/shared.d.ts +19 -0
  60. package/lib/types/tools/shared.d.ts.map +1 -0
  61. package/lib/types/tools/shared.js +44 -0
  62. package/lib/types/tools/shared.js.map +1 -0
  63. package/lib/types/tools/verify.d.ts +14 -0
  64. package/lib/types/tools/verify.d.ts.map +1 -0
  65. package/lib/types/tools/verify.js +160 -0
  66. package/lib/types/tools/verify.js.map +1 -0
  67. package/lib/types/verify.d.ts +124 -0
  68. package/lib/types/verify.d.ts.map +1 -0
  69. package/lib/types/verify.js +391 -0
  70. package/lib/types/verify.js.map +1 -0
  71. package/lib/types/version.d.ts +8 -0
  72. package/lib/types/version.d.ts.map +1 -0
  73. package/lib/types/version.js +8 -0
  74. package/lib/types/version.js.map +1 -0
  75. package/package.json +137 -0
  76. package/src/clean.ts +382 -0
  77. package/src/config.ts +104 -0
  78. package/src/dataset.ts +445 -0
  79. package/src/events.ts +90 -0
  80. package/src/index.ts +115 -0
  81. package/src/present.ts +38 -0
  82. package/src/profile.ts +250 -0
  83. package/src/provider-local.ts +194 -0
  84. package/src/service.ts +172 -0
  85. package/src/store.ts +74 -0
  86. package/src/tools/clean.ts +150 -0
  87. package/src/tools/profile.ts +94 -0
  88. package/src/tools/shared.ts +47 -0
  89. package/src/tools/verify.ts +163 -0
  90. package/src/verify.ts +496 -0
  91. package/src/version.ts +8 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The `data_clean` model tool: declarative cleaning rules through
3
+ * `ctx.dataQuality.cleanDataset`. The source file is never overwritten;
4
+ * without `outputPath` the run is preview-only.
5
+ * @module dsh-data-quality/tools/clean
6
+ */
7
+ import { defineTool } from '@deepseek-ai/dsh-tools';
8
+ import { renderCleanText, workspaceOf } from "./shared.js";
9
+ const STRING_MAP_SCHEMA = { type: 'json' };
10
+ const CLEAN_RULE_SCHEMA = {
11
+ type: 'array',
12
+ items: {
13
+ oneOf: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ rule: { type: 'string', const: 'dedupe', required: true },
18
+ columns: { type: 'array', items: { type: 'string' }, description: 'Key columns; all columns when omitted.' },
19
+ },
20
+ additionalProperties: false,
21
+ description: 'Remove rows whose key-column values duplicate an earlier row (first occurrence kept).',
22
+ },
23
+ {
24
+ type: 'object',
25
+ properties: {
26
+ rule: { type: 'string', const: 'fill-missing', required: true },
27
+ column: { type: 'string', required: true },
28
+ strategy: { type: 'string', enum: ['constant', 'mean', 'median', 'forward'], required: true },
29
+ value: { oneOf: [{ type: 'string' }, { type: 'number' }], description: 'Required for strategy "constant".' },
30
+ },
31
+ additionalProperties: false,
32
+ description: 'Fill missing cells: a constant, the column mean/median (numeric columns), or the previous non-missing value.',
33
+ },
34
+ {
35
+ type: 'object',
36
+ properties: {
37
+ rule: { type: 'string', const: 'coerce-type', required: true },
38
+ column: { type: 'string', required: true },
39
+ to: { type: 'string', enum: ['number', 'date', 'boolean'], required: true },
40
+ },
41
+ additionalProperties: false,
42
+ description: 'Coerce cells to number / ISO date / boolean; failures become missing and are counted in the log.',
43
+ },
44
+ {
45
+ type: 'object',
46
+ properties: {
47
+ rule: { type: 'string', const: 'normalize-unit', required: true },
48
+ column: { type: 'string', required: true },
49
+ factors: { ...STRING_MAP_SCHEMA, description: 'Unit suffix to multiplier, e.g. {"万": 10000, "亿": 100000000}.' },
50
+ },
51
+ additionalProperties: false,
52
+ description: 'Strip a unit suffix and multiply by its factor; plain numeric values convert too.',
53
+ },
54
+ {
55
+ type: 'object',
56
+ properties: {
57
+ rule: { type: 'string', const: 'trim', required: true },
58
+ columns: { type: 'array', items: { type: 'string' }, description: 'Columns to trim; all columns when omitted.' },
59
+ },
60
+ additionalProperties: false,
61
+ description: 'Trim leading/trailing whitespace of string cells.',
62
+ },
63
+ {
64
+ type: 'object',
65
+ properties: {
66
+ rule: { type: 'string', const: 'map-values', required: true },
67
+ column: { type: 'string', required: true },
68
+ map: { ...STRING_MAP_SCHEMA, description: 'Exact-match value mapping, e.g. {"Y": "yes", "N": "no"}.' },
69
+ else: { type: 'string', enum: ['keep', 'missing'], description: 'Policy for unmapped values (default keep).' },
70
+ },
71
+ additionalProperties: false,
72
+ description: 'Map enum values by exact match.',
73
+ },
74
+ ],
75
+ },
76
+ description: 'Ordered cleaning rules; each rule sees the previous rule\'s output.',
77
+ };
78
+ /**
79
+ * Build the `data_clean` tool definition against a mounted service.
80
+ * @param service - the mounted ctx.dataQuality implementation.
81
+ * @returns the tool definition to register.
82
+ */
83
+ export function defineCleanTool(service) {
84
+ return defineTool({
85
+ name: 'data_clean',
86
+ description: [
87
+ 'Apply declarative cleaning rules to a workspace CSV/TSV/JSON/JSONL dataset with deterministic TypeScript computation (no mental math).',
88
+ 'Rules apply in array order: dedupe (by column group), fill-missing (constant/mean/median/forward), coerce-type (number/date/boolean; failures counted and set to missing), normalize-unit (e.g. 万/亿 suffixes to base units), trim (whitespace), map-values (enum mapping).',
89
+ 'The source file is NEVER overwritten. Without outputPath the run is preview-only; with outputPath the cleaned dataset is written there (workspace-confined, .csv/.tsv/.json/.jsonl). Returns the per-rule audit log (affected rows per rule) plus a bounded preview. The full report persists to the data_quality storage domain (reportKey).',
90
+ ].join('\n'),
91
+ parameters: {
92
+ path: { type: 'string', required: true, description: 'Workspace-relative dataset path (.csv/.tsv/.json/.jsonl).' },
93
+ rules: { ...CLEAN_RULE_SCHEMA, required: true },
94
+ outputPath: { type: 'string', description: 'Optional workspace-relative output path for the cleaned dataset (must differ from path).' },
95
+ },
96
+ output: {
97
+ schema: {
98
+ type: 'object',
99
+ properties: {
100
+ dataset: { type: 'string', required: true },
101
+ inputRows: { type: 'number', required: true },
102
+ outputRows: { type: 'number', required: true },
103
+ generatedAt: { type: 'number', required: true },
104
+ outputPath: { type: 'string' },
105
+ reportKey: { type: 'string' },
106
+ logs: {
107
+ type: 'array',
108
+ items: {
109
+ type: 'object',
110
+ properties: {
111
+ ruleIndex: { type: 'number', required: true },
112
+ rule: { type: 'string', enum: ['dedupe', 'fill-missing', 'coerce-type', 'normalize-unit', 'trim', 'map-values'], required: true },
113
+ affectedRows: { type: 'number', required: true },
114
+ detail: { type: 'string', required: true },
115
+ },
116
+ additionalProperties: false,
117
+ },
118
+ required: true,
119
+ },
120
+ preview: {
121
+ type: 'object',
122
+ properties: {
123
+ columns: { type: 'array', items: { type: 'string' }, required: true },
124
+ rows: { type: 'array', items: { type: 'json' }, required: true },
125
+ },
126
+ additionalProperties: false,
127
+ required: true,
128
+ },
129
+ },
130
+ additionalProperties: false,
131
+ },
132
+ render: (_args, value) => [{ type: 'text', text: renderCleanText(value) }],
133
+ },
134
+ async execute(args, exec) {
135
+ return service.cleanDataset({
136
+ dataset: args.path,
137
+ rules: args.rules,
138
+ ...(args.outputPath !== undefined ? { outputPath: args.outputPath } : {}),
139
+ workspace: workspaceOf(exec),
140
+ session: exec.agent?.session,
141
+ signal: exec.signal,
142
+ });
143
+ },
144
+ });
145
+ }
146
+ //# sourceMappingURL=clean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../src/tools/clean.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE1D,MAAM,iBAAiB,GAAG,EAAE,IAAI,EA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AO,EAAE,IAAI,CAAC,IAAI;gBAClB,KAAK,EAAE,IAAI,CAAC,KAAwC;gBACpD,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzE,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC;gBAC5B,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO;gBAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The `data_profile` model tool: deterministic dataset profiling through
3
+ * `ctx.dataQuality.profileDataset` — never model arithmetic.
4
+ * @module dsh-data-quality/tools/profile
5
+ */
6
+ import type { DataQualityService } from '../service.js';
7
+ /**
8
+ * Build the `data_profile` tool definition against a mounted service.
9
+ * @param service - the mounted ctx.dataQuality implementation.
10
+ * @returns the tool definition to register.
11
+ */
12
+ export declare function defineProfileTool(service: DataQualityService): import("@deepseek-ai/dsh-tools").ToolDefinition;
13
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/tools/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAyCvD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,mDAwC5D"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The `data_profile` model tool: deterministic dataset profiling through
3
+ * `ctx.dataQuality.profileDataset` — never model arithmetic.
4
+ * @module dsh-data-quality/tools/profile
5
+ */
6
+ import { defineTool } from '@deepseek-ai/dsh-tools';
7
+ import { renderProfileText } from "../profile.js";
8
+ import { workspaceOf } from "./shared.js";
9
+ const COLUMN_PROFILE_SCHEMA = {
10
+ type: 'object',
11
+ properties: {
12
+ name: { type: 'string', required: true },
13
+ inferredType: { type: 'string', enum: ['number', 'date', 'boolean', 'string', 'empty', 'mixed'], required: true },
14
+ missing: { type: 'number', required: true },
15
+ missingRate: { type: 'number', required: true },
16
+ unique: { type: 'number', required: true },
17
+ numeric: {
18
+ type: 'object',
19
+ properties: {
20
+ min: { type: 'number', required: true },
21
+ max: { type: 'number', required: true },
22
+ mean: { type: 'number', required: true },
23
+ median: { type: 'number', required: true },
24
+ p25: { type: 'number', required: true },
25
+ p75: { type: 'number', required: true },
26
+ outliers: { type: 'number', required: true },
27
+ },
28
+ additionalProperties: false,
29
+ },
30
+ topValues: {
31
+ type: 'array',
32
+ items: {
33
+ type: 'object',
34
+ properties: {
35
+ value: { type: 'string', required: true },
36
+ count: { type: 'number', required: true },
37
+ },
38
+ additionalProperties: false,
39
+ },
40
+ },
41
+ notes: { type: 'array', items: { type: 'string' }, required: true },
42
+ },
43
+ additionalProperties: false,
44
+ };
45
+ /**
46
+ * Build the `data_profile` tool definition against a mounted service.
47
+ * @param service - the mounted ctx.dataQuality implementation.
48
+ * @returns the tool definition to register.
49
+ */
50
+ export function defineProfileTool(service) {
51
+ return defineTool({
52
+ name: 'data_profile',
53
+ description: [
54
+ 'Profile a workspace CSV/TSV/JSON/JSONL dataset with deterministic TypeScript computation (no mental math).',
55
+ 'Returns row/column counts, inferred column types, missing rates, unique counts, numeric distributions (min/max/mean/median/p25/p75), IQR outlier counts, mixed-type suspicion notes, and duplicate-row counts.',
56
+ 'Column cards cover every row by default; pass sample for a deterministic systematic sample on large files. Datasets above the configured row/size caps are rejected — use sample or raise the caps. The full report persists to the data_quality storage domain (reportKey in the result).',
57
+ ].join('\n'),
58
+ parameters: {
59
+ path: { type: 'string', required: true, description: 'Workspace-relative dataset path (.csv/.tsv/.json/.jsonl). JSON datasets must be an array of flat objects.' },
60
+ sample: { type: 'number', description: 'Optional systematic sample size (every ceil(N/sample)-th row) for the column cards; row counts stay exact.' },
61
+ },
62
+ output: {
63
+ schema: {
64
+ type: 'object',
65
+ properties: {
66
+ dataset: { type: 'string', required: true },
67
+ rowCount: { type: 'number', required: true },
68
+ sampled: { type: 'boolean', required: true },
69
+ profiledRows: { type: 'number', required: true },
70
+ columnCount: { type: 'number', required: true },
71
+ duplicateRows: { type: 'number', required: true },
72
+ generatedAt: { type: 'number', required: true },
73
+ reportKey: { type: 'string' },
74
+ columns: { type: 'array', items: COLUMN_PROFILE_SCHEMA, required: true },
75
+ },
76
+ additionalProperties: false,
77
+ },
78
+ render: (_args, value) => [{ type: 'text', text: renderProfileText(value) }],
79
+ },
80
+ async execute(args, exec) {
81
+ return service.profileDataset({
82
+ dataset: args.path,
83
+ sample: args.sample,
84
+ workspace: workspaceOf(exec),
85
+ session: exec.agent?.session,
86
+ signal: exec.signal,
87
+ });
88
+ },
89
+ });
90
+ }
91
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/tools/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;QACjH,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3C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,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;SAC7E;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI;YACtB,OAAO,OAAO,CAAC,cAAc,CAAC;gBAC5B,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC;gBAC5B,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO;gBAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shared helpers for the three data-quality model tools: session workspace
3
+ * resolution and a compact cleaning-run text render. Kept presentation-only;
4
+ * computation lives in the engines and the provider.
5
+ * @module dsh-data-quality/tools-shared
6
+ */
7
+ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
8
+ import type { CleanRunReport } from '../service.js';
9
+ /**
10
+ * The absolute workspace root a tool call resolves dataset paths against: the
11
+ * calling agent's per-session cwd (mirroring the official fs tools). Non-agent
12
+ * calls fail loud — there is no honest workspace to confine paths to.
13
+ * @param exec - the tool-execution context.
14
+ * @returns the absolute workspace root.
15
+ */
16
+ export declare function workspaceOf(exec: ToolExecution): string;
17
+ /** Human-readable cleaning summary for the tool's Native render. */
18
+ export declare function renderCleanText(report: CleanRunReport): string;
19
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/tools/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAMvD;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAmB9D"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared helpers for the three data-quality model tools: session workspace
3
+ * resolution and a compact cleaning-run text render. Kept presentation-only;
4
+ * computation lives in the engines and the provider.
5
+ * @module dsh-data-quality/tools-shared
6
+ */
7
+ import path from 'node:path';
8
+ /**
9
+ * The absolute workspace root a tool call resolves dataset paths against: the
10
+ * calling agent's per-session cwd (mirroring the official fs tools). Non-agent
11
+ * calls fail loud — there is no honest workspace to confine paths to.
12
+ * @param exec - the tool-execution context.
13
+ * @returns the absolute workspace root.
14
+ */
15
+ export function workspaceOf(exec) {
16
+ const cwd = exec.agent?.session.header.cwd;
17
+ if (cwd === undefined) {
18
+ throw new Error('data-quality tools require an agent-owned session workspace');
19
+ }
20
+ return path.resolve(cwd);
21
+ }
22
+ /** Human-readable cleaning summary for the tool's Native render. */
23
+ export function renderCleanText(report) {
24
+ const lines = [];
25
+ lines.push(`Cleaned ${report.dataset}: ${report.inputRows} -> ${report.outputRows} rows over ${report.logs.length} rule(s)`);
26
+ for (const log of report.logs) {
27
+ lines.push(`- rule ${log.ruleIndex} (${log.rule}): ${log.affectedRows} row(s) affected; ${log.detail}`);
28
+ }
29
+ if (report.outputPath !== undefined) {
30
+ lines.push(`Wrote cleaned dataset to ${report.outputPath}`);
31
+ }
32
+ else {
33
+ lines.push('No outputPath given: the source file was left untouched; preview below.');
34
+ }
35
+ if (report.preview.rows.length > 0) {
36
+ lines.push(`Preview (first ${report.preview.rows.length} row(s)):`);
37
+ for (const row of report.preview.rows) {
38
+ const cells = report.preview.columns.map((column) => `${column}=${JSON.stringify(row[column] ?? null)}`).join(', ');
39
+ lines.push(` ${cells}`);
40
+ }
41
+ }
42
+ return lines.join('\n');
43
+ }
44
+ //# sour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KAAK,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,CAAA;QACnE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACnH,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The `data_verify` model tool: declarative verification rules through
3
+ * `ctx.dataQuality.verifyDataset`. A failing dataset is a normal result
4
+ * (`passed: false` with evidence), never a tool error.
5
+ * @module dsh-data-quality/tools/verify
6
+ */
7
+ import type { DataQualityService } from '../service.js';
8
+ /**
9
+ * Build the `data_verify` tool definition against a mounted service.
10
+ * @param service - the mounted ctx.dataQuality implementation.
11
+ * @returns the tool definition to register.
12
+ */
13
+ export declare function defineVerifyTool(service: DataQualityService): import("@deepseek-ai/dsh-tools").ToolDefinition;
14
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/tools/verify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAA;AAsFnE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,mDA+D3D"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * The `data_verify` model tool: declarative verification rules through
3
+ * `ctx.dataQuality.verifyDataset`. A failing dataset is a normal result
4
+ * (`passed: false` with evidence), never a tool error.
5
+ * @module dsh-data-quality/tools/verify
6
+ */
7
+ import { defineTool } from '@deepseek-ai/dsh-tools';
8
+ import { renderVerifyText } from "../verify.js";
9
+ import { workspaceOf } from "./shared.js";
10
+ const VERIFY_RULE_SCHEMA = {
11
+ type: 'array',
12
+ items: {
13
+ oneOf: [
14
+ {
15
+ type: 'object',
16
+ properties: {
17
+ rule: { type: 'string', const: 'not-null', required: true },
18
+ column: { type: 'string', required: true },
19
+ },
20
+ additionalProperties: false,
21
+ description: 'Fail rows where the column is missing (null/empty/whitespace).',
22
+ },
23
+ {
24
+ type: 'object',
25
+ properties: {
26
+ rule: { type: 'string', const: 'unique', required: true },
27
+ columns: { type: 'array', items: { type: 'string' }, required: true, description: 'Key columns; every row whose key repeats fails.' },
28
+ },
29
+ additionalProperties: false,
30
+ description: 'Fail rows whose key-column combination appears more than once.',
31
+ },
32
+ {
33
+ type: 'object',
34
+ properties: {
35
+ rule: { type: 'string', const: 'range', required: true },
36
+ column: { type: 'string', required: true },
37
+ min: { type: 'number' },
38
+ max: { type: 'number' },
39
+ },
40
+ additionalProperties: false,
41
+ description: 'Fail rows where the numeric cell is missing, unparseable, or outside [min, max] (inclusive; at least one bound required).',
42
+ },
43
+ {
44
+ type: 'object',
45
+ properties: {
46
+ rule: { type: 'string', const: 'regex', required: true },
47
+ column: { type: 'string', required: true },
48
+ pattern: { type: 'string', required: true },
49
+ flags: { type: 'string', description: 'Optional JS regex flags, e.g. "i".' },
50
+ },
51
+ additionalProperties: false,
52
+ description: 'Fail rows where the cell is missing or does not match the pattern (full JS regex semantics).',
53
+ },
54
+ {
55
+ type: 'object',
56
+ properties: {
57
+ rule: { type: 'string', const: 'enum', required: true },
58
+ column: { type: 'string', required: true },
59
+ values: { type: 'array', items: { type: 'string' }, required: true },
60
+ },
61
+ additionalProperties: false,
62
+ description: 'Fail rows where the trimmed cell text is not one of the allowed values.',
63
+ },
64
+ {
65
+ type: 'object',
66
+ properties: {
67
+ rule: { type: 'string', const: 'cross-column', required: true },
68
+ left: { type: 'string', required: true, description: 'Left column name.' },
69
+ op: { type: 'string', enum: ['<', '<=', '==', '!=', '>=', '>'], required: true },
70
+ rightColumn: { type: 'string', description: 'Compare against another column…' },
71
+ value: { oneOf: [{ type: 'number' }, { type: 'string' }], description: '…or against this literal (exactly one of rightColumn/value).' },
72
+ },
73
+ additionalProperties: false,
74
+ description: 'Compare two columns (e.g. startDate < endDate) or a column against a literal. Numeric when both sides parse, string equality for ==/!= otherwise.',
75
+ },
76
+ {
77
+ type: 'object',
78
+ properties: {
79
+ rule: { type: 'string', const: 'freshness', required: true },
80
+ column: { type: 'string', required: true, description: 'Date column (YYYY-MM-DD, YYYY/MM/DD, or ISO datetime).' },
81
+ maxAgeDays: { type: 'number', required: true, description: 'Fail rows whose date is older than this many days before asOf.' },
82
+ asOf: { type: 'string', description: 'Reference date; defaults to the current date.' },
83
+ },
84
+ additionalProperties: false,
85
+ description: 'Fail rows whose date cell is missing, unparseable, or older than maxAgeDays before asOf.',
86
+ },
87
+ ],
88
+ },
89
+ description: 'Verification rules; a missing cell fails every rule that reads it.',
90
+ };
91
+ /**
92
+ * Build the `data_verify` tool definition against a mounted service.
93
+ * @param service - the mounted ctx.dataQuality implementation.
94
+ * @returns the tool definition to register.
95
+ */
96
+ export function defineVerifyTool(service) {
97
+ return defineTool({
98
+ name: 'data_verify',
99
+ description: [
100
+ 'Verify a workspace CSV/TSV/JSON/JSONL dataset against declarative quality rules with deterministic TypeScript computation (no mental math).',
101
+ 'Rules: not-null, unique (column group), range (numeric bounds), regex, enum, cross-column (e.g. startDate < endDate), freshness (date column within N days of asOf). A missing cell fails every rule that reads it.',
102
+ 'Returns per-rule pass/fail with capped failing-row evidence. Overall failure is a NORMAL result with passed: false — not a tool error. The full report persists to the data_quality storage domain (reportKey).',
103
+ ].join('\n'),
104
+ parameters: {
105
+ path: { type: 'string', required: true, description: 'Workspace-relative dataset path (.csv/.tsv/.json/.jsonl).' },
106
+ rules: { ...VERIFY_RULE_SCHEMA, required: true },
107
+ },
108
+ output: {
109
+ schema: {
110
+ type: 'object',
111
+ properties: {
112
+ dataset: { type: 'string', required: true },
113
+ passed: { type: 'boolean', required: true },
114
+ rowCount: { type: 'number', required: true },
115
+ generatedAt: { type: 'number', required: true },
116
+ reportKey: { type: 'string' },
117
+ rules: {
118
+ type: 'array',
119
+ items: {
120
+ type: 'object',
121
+ properties: {
122
+ ruleIndex: { type: 'number', required: true },
123
+ rule: { type: 'string', enum: ['not-null', 'unique', 'range', 'regex', 'enum', 'cross-column', 'freshness'], required: true },
124
+ passed: { type: 'boolean', required: true },
125
+ failedCount: { type: 'number', required: true },
126
+ checkedCount: { type: 'number', required: true },
127
+ evidence: {
128
+ type: 'array',
129
+ items: {
130
+ type: 'object',
131
+ properties: {
132
+ rowIndex: { type: 'number', required: true },
133
+ values: { type: 'json', required: true },
134
+ },
135
+ additionalProperties: false,
136
+ },
137
+ required: true,
138
+ },
139
+ },
140
+ additionalProperties: false,
141
+ },
142
+ required: true,
143
+ },
144
+ },
145
+ additionalProperties: false,
146
+ },
147
+ render: (_args, value) => [{ type: 'text', text: renderVerifyText(value) }],
148
+ },
149
+ async execute(args, exec) {
150
+ return service.verifyDataset({
151
+ dataset: args.path,
152
+ rules: args.rules,
153
+ workspace: workspaceOf(exec),
154
+ session: exec.agent?.session,
155
+ signal: exec.signal,
156
+ });
157
+ },
158
+ });
159
+ }
160
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/tools/verify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,gBAAgB,EAAqB,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAA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