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,163 @@
1
+ /**
2
+ * The local deterministic Provider of the `ctx.dataQuality` seam: orchestrates
3
+ * dataset loading, the pure engines, durable report persistence, and the
4
+ * adaptive `data-quality/*` session events. All computation is TypeScript in
5
+ * this process — no model arithmetic, no external processes.
6
+ * @module dsh-data-quality/provider-local
7
+ */
8
+ import { mkdir, writeFile } from 'node:fs/promises';
9
+ import path from 'node:path';
10
+ import { loadDocument, loadTable, resolveWorkspacePath, throwIfAborted } from "./dataset.js";
11
+ import { applyCleanRules, serializeDelimited } from "./clean.js";
12
+ import { profileTable } from "./profile.js";
13
+ import { checkCitations, verifyTable } from "./verify.js";
14
+ import { appendDataQualityEvent } from "./events.js";
15
+ import { reportKeyOf } from "./store.js";
16
+ import { truncateRow } from "./present.js";
17
+ import { DataQualityService, } from "./service.js";
18
+ /**
19
+ * The local deterministic `dataQuality` implementation. Mounted by the plugin
20
+ * entry; third-party plugins consume it through `ctx.dataQuality`.
21
+ */
22
+ export class LocalDataQualityService extends DataQualityService {
23
+ config;
24
+ deps;
25
+ /**
26
+ * @param ctx - the plugin context.
27
+ * @param config - the resolved plugin config.
28
+ * @param deps - store handle plus the injected clock.
29
+ */
30
+ constructor(ctx, config, deps) {
31
+ super(ctx);
32
+ this.config = config;
33
+ this.deps = deps;
34
+ }
35
+ /** The absolute root for service-level calls without a session workspace. */
36
+ serviceRoot() {
37
+ return this.config.workspaceRoot !== '' ? path.resolve(this.config.workspaceRoot) : process.cwd();
38
+ }
39
+ /** Persist one report when persistence is on; returns the storage key. */
40
+ async persist(kind, dataset, report) {
41
+ const store = this.deps.store;
42
+ if (store === undefined)
43
+ return undefined;
44
+ const record = { kind, at: this.deps.now(), dataset, report };
45
+ const key = reportKeyOf(record);
46
+ await store.put({ ...record });
47
+ return key;
48
+ }
49
+ /** Emit the adaptive session event when the call carries a session. */
50
+ emitEvent(session, kind, dataset, reportKey, summary) {
51
+ if (session === undefined)
52
+ return;
53
+ appendDataQualityEvent(session, `data-quality/${kind}`, {
54
+ kind,
55
+ dataset,
56
+ ...(reportKey !== undefined ? { reportKey } : {}),
57
+ summary,
58
+ });
59
+ }
60
+ /** @inheritdoc DataQualityService.profileDataset */
61
+ async profileDataset(request) {
62
+ throwIfAborted(request.signal);
63
+ const absolute = resolveWorkspacePath(request.workspace, request.dataset, this.config);
64
+ const table = await loadTable(absolute, this.config, request.signal);
65
+ const report = profileTable(table, {
66
+ dataset: request.dataset,
67
+ sample: request.sample,
68
+ generatedAt: this.deps.now(),
69
+ signal: request.signal,
70
+ });
71
+ const reportKey = await this.persist('profile', request.dataset, report);
72
+ this.emitEvent(request.session, 'profile', request.dataset, reportKey, { rows: report.rowCount, columns: report.columnCount });
73
+ return { ...report, ...(reportKey !== undefined ? { reportKey } : {}) };
74
+ }
75
+ /** @inheritdoc DataQualityService.cleanDataset */
76
+ async cleanDataset(request) {
77
+ throwIfAborted(request.signal);
78
+ const absolute = resolveWorkspacePath(request.workspace, request.dataset, this.config);
79
+ const table = await loadTable(absolute, this.config, request.signal);
80
+ const result = applyCleanRules(table, request.rules, { signal: request.signal });
81
+ let writtenPath;
82
+ if (request.outputPath !== undefined) {
83
+ const outputAbsolute = resolveWorkspacePath(request.workspace, request.outputPath, this.config);
84
+ if (outputAbsolute === absolute) {
85
+ throw new Error(`outputPath ${JSON.stringify(request.outputPath)} would overwrite the input dataset; choose a different path`);
86
+ }
87
+ const ext = path.extname(outputAbsolute).toLowerCase();
88
+ const text = ext === '.csv' || ext === '.tsv'
89
+ ? serializeDelimited(result.columns, result.rows, ext === '.csv' ? ',' : '\t')
90
+ : ext === '.jsonl'
91
+ ? `${result.rows.map((row) => JSON.stringify(row)).join('\n')}\n`
92
+ : `${JSON.stringify(result.rows, null, 2)}\n`;
93
+ await mkdir(path.dirname(outputAbsolute), { recursive: true });
94
+ throwIfAborted(request.signal);
95
+ await writeFile(outputAbsolute, text, 'utf8');
96
+ writtenPath = request.outputPath;
97
+ }
98
+ const generatedAt = this.deps.now();
99
+ const reportKey = await this.persist('clean', request.dataset, {
100
+ dataset: request.dataset,
101
+ inputRows: result.inputRows,
102
+ outputRows: result.outputRows,
103
+ logs: result.logs,
104
+ ...(writtenPath !== undefined ? { outputPath: writtenPath } : {}),
105
+ generatedAt,
106
+ });
107
+ this.emitEvent(request.session, 'clean', request.dataset, reportKey, { rows: result.outputRows, columns: result.columns.length, rules: result.logs.length });
108
+ const previewRows = result.rows.slice(0, this.config.evidenceRowLimit).map((row) => truncateRow(row));
109
+ return {
110
+ dataset: request.dataset,
111
+ inputRows: result.inputRows,
112
+ outputRows: result.outputRows,
113
+ logs: result.logs,
114
+ preview: { columns: result.columns, rows: previewRows },
115
+ ...(writtenPath !== undefined ? { outputPath: writtenPath } : {}),
116
+ ...(reportKey !== undefined ? { reportKey } : {}),
117
+ generatedAt,
118
+ };
119
+ }
120
+ /** @inheritdoc DataQualityService.verifyDataset */
121
+ async verifyDataset(request) {
122
+ throwIfAborted(request.signal);
123
+ const absolute = resolveWorkspacePath(request.workspace, request.dataset, this.config);
124
+ const table = await loadTable(absolute, this.config, request.signal);
125
+ const outcome = verifyTable(table, request.rules, {
126
+ evidenceRowLimit: this.config.evidenceRowLimit,
127
+ now: this.deps.now,
128
+ signal: request.signal,
129
+ });
130
+ const report = { dataset: request.dataset, ...outcome };
131
+ const failedRules = report.rules.filter((rule) => !rule.passed).length;
132
+ const reportKey = await this.persist('verify', request.dataset, report);
133
+ this.emitEvent(request.session, 'verify', request.dataset, reportKey, {
134
+ rows: report.rowCount,
135
+ rules: report.rules.length,
136
+ failedRules,
137
+ passed: report.passed,
138
+ });
139
+ return { ...report, ...(reportKey !== undefined ? { reportKey } : {}) };
140
+ }
141
+ /** @inheritdoc DataQualityService.verifyCitations */
142
+ async verifyCitations(request) {
143
+ const absolute = resolveWorkspacePath(this.serviceRoot(), request.dataset, this.config);
144
+ const document = await loadDocument(absolute, this.config);
145
+ const result = checkCitations(document, request.citations, this.config.defaultTolerance);
146
+ const verified = result.results.filter((entry) => entry.status === 'verified').length;
147
+ const mismatched = result.results.filter((entry) => entry.status === 'mismatch').length;
148
+ const notFound = result.results.filter((entry) => entry.status === 'not-found').length;
149
+ const unverifiable = result.results.filter((entry) => entry.status === 'unverifiable').length;
150
+ await this.persist('citations', request.dataset, {
151
+ dataset: request.dataset,
152
+ checked: result.results.length,
153
+ verified,
154
+ mismatched,
155
+ notFound,
156
+ unverifiable,
157
+ results: result.results,
158
+ generatedAt: this.deps.now(),
159
+ });
160
+ return result;
161
+ }
162
+ }
163
+ //# sourceMappingURL=provider-local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-local.js","sourceRoot":"","sources":["../../src/provider-local.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAA;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EACL,kBAAkB,GAOnB,MAAM,cAAc,CAAA;AAarB;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,kBAAkB;IAC5C,MAAM,CAAgB;IACtB,IAAI,CAAc;IAEnC;;;;OAIG;IACH,YAAY,GAAY,EAAE,MAAsB,EAAE,IAAkB;QAClE,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,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,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,MAAM,CAAA;QAC7F,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE;YAC/C,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;YAC9B,QAAQ;YACR,UAAU;YACV,QAAQ;YACR,YAAY;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;SACS,CAAC,CAAA;QACxC,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Service Definition of the `dsh-data-quality` capability seam: the
3
+ * `ctx.dataQuality` surface other plugins may optionally consume, plus the
4
+ * internal request/report types the local Provider and the tool Consumers
5
+ * share. The {@link CitationCheckRequest} / {@link CitationCheckResult}
6
+ * citation contract is FROZEN for cross-plugin consumers — change it only
7
+ * with a coordinated ecosystem migration.
8
+ * @module dsh-data-quality/service
9
+ */
10
+ import { Service, type Context } from '@deepseek-ai/cordis';
11
+ import type { JsonValue, Session } from '@deepseek-ai/dsh-session';
12
+ import type { CleanRule, CleanRuleLog } from './clean.js';
13
+ import type { ProfileReport } from './profile.js';
14
+ import type { VerifyReport, VerifyRule } from './verify.js';
15
+ export interface CitationCheckRequest {
16
+ /** Workspace-relative path of the source dataset snapshot (CSV/JSON). */
17
+ dataset: string;
18
+ /** Citations to verify against the dataset. */
19
+ citations: Array<{
20
+ /** Stable id chosen by the caller, echoed back in results. */
21
+ id: string;
22
+ /** JSON-path-ish locator, e.g. "rows[3].nav" or "summary.annualReturn". */
23
+ path: string;
24
+ /** The value as cited in the document. */
25
+ value: number | string;
26
+ /** Optional relative tolerance for numeric comparison, e.g. 0.01 = 1%. */
27
+ tolerance?: number;
28
+ }>;
29
+ }
30
+ export interface CitationCheckResult {
31
+ results: Array<{
32
+ id: string;
33
+ status: 'verified' | 'mismatch' | 'not-found' | 'unverifiable';
34
+ /** Actual value found at path, when found. */
35
+ actual?: number | string;
36
+ /** Human-readable evidence note. */
37
+ note?: string;
38
+ }>;
39
+ }
40
+ /** Profile request through the service layer (tools pass the session workspace). */
41
+ export interface ProfileRequest {
42
+ /** Workspace-relative dataset path. */
43
+ readonly dataset: string;
44
+ /** Optional deterministic systematic sample size for column cards. */
45
+ readonly sample?: number | undefined;
46
+ /** Absolute workspace root the dataset resolves inside. */
47
+ readonly workspace: string;
48
+ /** Calling session (receives the `data-quality/profile` event), when any. */
49
+ readonly session?: Session | undefined;
50
+ /** Cancellation from the tool call. */
51
+ readonly signal?: AbortSignal | undefined;
52
+ }
53
+ /** Clean request through the service layer. */
54
+ export interface CleanRequest {
55
+ /** Workspace-relative dataset path. */
56
+ readonly dataset: string;
57
+ /** Non-empty declarative cleaning rule list, applied in order. */
58
+ readonly rules: readonly CleanRule[];
59
+ /** Workspace-relative output path; omitted = no disk write, preview only. */
60
+ readonly outputPath?: string | undefined;
61
+ /** Absolute workspace root the dataset resolves inside. */
62
+ readonly workspace: string;
63
+ /** Calling session (receives the `data-quality/clean` event), when any. */
64
+ readonly session?: Session | undefined;
65
+ /** Cancellation from the tool call. */
66
+ readonly signal?: AbortSignal | undefined;
67
+ }
68
+ /** Verify request through the service layer. */
69
+ export interface VerifyRequest {
70
+ /** Workspace-relative dataset path. */
71
+ readonly dataset: string;
72
+ /** Non-empty declarative verification rule list. */
73
+ readonly rules: readonly VerifyRule[];
74
+ /** Absolute workspace root the dataset resolves inside. */
75
+ readonly workspace: string;
76
+ /** Calling session (receives the `data-quality/verify` event), when any. */
77
+ readonly session?: Session | undefined;
78
+ /** Cancellation from the tool call. */
79
+ readonly signal?: AbortSignal | undefined;
80
+ }
81
+ /** The value a clean run returns (tool canonical value minus presentation). */
82
+ export interface CleanRunReport {
83
+ readonly dataset: string;
84
+ readonly inputRows: number;
85
+ readonly outputRows: number;
86
+ readonly logs: CleanRuleLog[];
87
+ /** First `evidenceRowLimit` cleaned rows for inspection (display-truncated). */
88
+ readonly preview: {
89
+ readonly columns: string[];
90
+ readonly rows: Array<Record<string, JsonValue>>;
91
+ };
92
+ /** Workspace-relative output path when the run wrote a file. */
93
+ readonly outputPath?: string;
94
+ /** Storage-domain key of the persisted report, when persistence is on. */
95
+ readonly reportKey?: string;
96
+ readonly generatedAt: number;
97
+ }
98
+ /** The value a verifyCitation call persists (report envelope kind `citations`). */
99
+ export interface CitationCheckPersisted {
100
+ readonly dataset: string;
101
+ readonly checked: number;
102
+ readonly verified: number;
103
+ readonly mismatched: number;
104
+ readonly notFound: number;
105
+ readonly unverifiable: number;
106
+ readonly results: CitationCheckResult['results'];
107
+ readonly generatedAt: number;
108
+ }
109
+ /**
110
+ * The `ctx.dataQuality` service. The local Provider implements deterministic
111
+ * TypeScript computation; Consumers (the three tools and third-party plugins)
112
+ * never re-implement the math.
113
+ */
114
+ export declare abstract class DataQualityService extends Service {
115
+ /**
116
+ * Register as `dataQuality` on the context.
117
+ * @param ctx - the plugin context.
118
+ */
119
+ constructor(ctx: Context);
120
+ /**
121
+ * Frozen cross-plugin contract: verify document citations against a dataset
122
+ * snapshot. The dataset resolves against the configured service workspace
123
+ * root (`workspaceRoot`, defaulting to the harness launch directory).
124
+ * @param request - dataset path plus citations.
125
+ * @returns one result per citation, ids echoed.
126
+ */
127
+ abstract verifyCitations(request: CitationCheckRequest): Promise<CitationCheckResult>;
128
+ /**
129
+ * Profile a workspace dataset (row/column counts, inferred types,
130
+ * missingness, cardinality, numeric distribution, suspected anomalies).
131
+ * @param request - dataset path, optional sample size, workspace root.
132
+ * @returns the profile report.
133
+ */
134
+ abstract profileDataset(request: ProfileRequest): Promise<ProfileReport>;
135
+ /**
136
+ * Apply declarative cleaning rules to a workspace dataset. The source file
137
+ * is never overwritten; without `outputPath` nothing touches the disk.
138
+ * @param request - dataset path, ordered rules, optional output path, workspace root.
139
+ * @returns the cleaned preview plus the per-rule audit log.
140
+ */
141
+ abstract cleanDataset(request: CleanRequest): Promise<CleanRunReport>;
142
+ /**
143
+ * Apply declarative verification rules to a workspace dataset. A failing
144
+ * dataset is a normal result (`passed: false`), never a thrown error.
145
+ * @param request - dataset path, rules, workspace root.
146
+ * @returns the verify report.
147
+ */
148
+ abstract verifyDataset(request: VerifyRequest): Promise<VerifyReport>;
149
+ }
150
+ declare module '@deepseek-ai/cordis' {
151
+ interface Context {
152
+ /** Deterministic data profiling / cleaning / verification, when the dsh-data-quality bundle is mounted. */
153
+ dataQuality: DataQualityService;
154
+ }
155
+ }
156
+ /** Re-exports so consumers pull the whole seam vocabulary from one module. */
157
+ export type { CleanResult, CleanRule, CleanRuleLog } from './clean.js';
158
+ export type { ProfileReport } from './profile.js';
159
+ export type { VerifyReport, VerifyRule } from './verify.js';
160
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE3D,MAAM,WAAW,oBAAoB;IACnC,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,SAAS,EAAE,KAAK,CAAC;QACf,8DAA8D;QAC9D,EAAE,EAAE,MAAM,CAAA;QACV,2EAA2E;QAC3E,IAAI,EAAE,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C,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;GAIG;AACH,8BAAsB,kBAAmB,SAAQ,OAAO;IACtD;;;OAGG;gBACS,GAAG,EAAE,OAAO;IAIxB;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAErF;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAExE;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAErE;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CACtE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,2GAA2G;QAC3G,WAAW,EAAE,kBAAkB,CAAA;KAChC;CACF;AAED,8EAA8E;AAC9E,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Service Definition of the `dsh-data-quality` capability seam: the
3
+ * `ctx.dataQuality` surface other plugins may optionally consume, plus the
4
+ * internal request/report types the local Provider and the tool Consumers
5
+ * share. The {@link CitationCheckRequest} / {@link CitationCheckResult}
6
+ * citation contract is FROZEN for cross-plugin consumers — change it only
7
+ * with a coordinated ecosystem migration.
8
+ * @module dsh-data-quality/service
9
+ */
10
+ import { Service } from '@deepseek-ai/cordis';
11
+ /**
12
+ * The `ctx.dataQuality` service. The local Provider implements deterministic
13
+ * TypeScript computation; Consumers (the three tools and third-party plugins)
14
+ * never re-implement the math.
15
+ */
16
+ export class DataQualityService extends Service {
17
+ /**
18
+ * Register as `dataQuality` on the context.
19
+ * @param ctx - the plugin context.
20
+ */
21
+ constructor(ctx) {
22
+ super(ctx, 'dataQuality');
23
+ }
24
+ }
25
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,qBAAqB,CAAA;AAuG3D;;;;GAIG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,OAAO;IACtD;;;OAGG;IACH,YAAY,GAAY;QACtB,KAAK,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC3B,CAAC;CAkCF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Durable report storage over the harness storage domain. The `data_quality`
3
+ * domain keeps one record per profile/clean/verify/citations run, keyed by an
4
+ * injected timestamp plus a path fingerprint, so reports survive a restart
5
+ * and stay queryable without touching the session log.
6
+ * @module dsh-data-quality/store
7
+ */
8
+ import z from 'zod';
9
+ /** Zod schema of one persisted report record (durable-boundary validation). */
10
+ export declare const reportRecordSchema: z.ZodObject<{
11
+ kind: z.ZodEnum<{
12
+ profile: "profile";
13
+ clean: "clean";
14
+ verify: "verify";
15
+ citations: "citations";
16
+ }>;
17
+ at: z.ZodNumber;
18
+ dataset: z.ZodString;
19
+ report: z.ZodRecord<z.ZodString, z.ZodUnknown>;
20
+ }, z.core.$strip>;
21
+ /** One persisted report record. */
22
+ export interface ReportRecord {
23
+ readonly kind: 'profile' | 'clean' | 'verify' | 'citations';
24
+ /** Injected run timestamp (epoch ms). */
25
+ readonly at: number;
26
+ /** Workspace-relative dataset path as the caller gave it. */
27
+ readonly dataset: string;
28
+ /** The full run report (profile/clean/verify/citations shape by `kind`). */
29
+ readonly report: Record<string, unknown>;
30
+ }
31
+ /** The `dsh-data-quality` storage-domain declaration. */
32
+ export declare const dataQualityDomainSpec: {
33
+ name: string;
34
+ version: number;
35
+ tables: {
36
+ reports: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<string, ReportRecord>;
37
+ };
38
+ };
39
+ /** Handle over the reports table with deterministic key construction. */
40
+ export interface ReportStore {
41
+ /**
42
+ * Persist one run report.
43
+ * @param record - the report envelope (kind/dataset/at/report).
44
+ * @returns the storage key the record was written under.
45
+ */
46
+ put(record: ReportRecord): Promise<string>;
47
+ /**
48
+ * Read one persisted report.
49
+ * @param key - the key {@link put} returned.
50
+ * @returns the record, or `undefined` when absent.
51
+ */
52
+ get(key: string): ReportRecord | undefined;
53
+ }
54
+ /**
55
+ * Build the storage key for one run: `YYYYMMDDHHmmssSSS-<kind>-<pathFp>`.
56
+ * UTC digits keep the key timezone-independent and filename-safe everywhere.
57
+ * @param record - the report envelope.
58
+ * @returns the deterministic key.
59
+ */
60
+ export declare function reportKeyOf(record: ReportRecord): string;
61
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,CAAC,MAAM,KAAK,CAAA;AAInB,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAK7B,CAAA;AAEF,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAA;IAC3D,yCAAyC;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC;AAED,yDAAyD;AACzD,eAAO,MAAM,qBAAqB;;;;;;CAMhC,CAAA;AAEF,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1C;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAA;CAC3C;AAOD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAMxD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Durable report storage over the harness storage domain. The `data_quality`
3
+ * domain keeps one record per profile/clean/verify/citations run, keyed by an
4
+ * injected timestamp plus a path fingerprint, so reports survive a restart
5
+ * and stay queryable without touching the session log.
6
+ * @module dsh-data-quality/store
7
+ */
8
+ import z from 'zod';
9
+ import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';
10
+ import { pathFingerprint } from "./dataset.js";
11
+ /** Zod schema of one persisted report record (durable-boundary validation). */
12
+ export const reportRecordSchema = z.object({
13
+ kind: z.enum(['profile', 'clean', 'verify', 'citations']),
14
+ at: z.number().int().nonnegative(),
15
+ dataset: z.string(),
16
+ report: z.record(z.string(), z.unknown()),
17
+ });
18
+ /** The `dsh-data-quality` storage-domain declaration. */
19
+ export const dataQualityDomainSpec = defineDomain({
20
+ name: 'data_quality',
21
+ version: 1,
22
+ tables: {
23
+ reports: domainTable(reportRecordSchema),
24
+ },
25
+ });
26
+ /** Pad to two digits for the key timestamp. */
27
+ function pad2(value) {
28
+ return String(value).padStart(2, '0');
29
+ }
30
+ /**
31
+ * Build the storage key for one run: `YYYYMMDDHHmmssSSS-<kind>-<pathFp>`.
32
+ * UTC digits keep the key timezone-independent and filename-safe everywhere.
33
+ * @param record - the report envelope.
34
+ * @returns the deterministic key.
35
+ */
36
+ export function reportKeyOf(record) {
37
+ const date = new Date(record.at);
38
+ const stamp = `${date.getUTCFullYear()}${pad2(date.getUTCMonth() + 1)}${pad2(date.getUTCDate())}` +
39
+ `${pad2(date.getUTCHours())}${pad2(date.getUTCMinutes())}${pad2(date.getUTCSeconds())}${String(date.getUTCMilliseconds()).padStart(3, '0')}`;
40
+ return `${stamp}-${record.kind}-${pathFingerprint(record.dataset)}`;
41
+ }
42
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACzD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAClC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;CAC1C,CAAC,CAAA;AAaF,yDAAyD;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;IAChD,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,CAAC;IACV,MAAM,EAAE;QACN,OAAO,EAAE,WAAW,CAAuB,kBAAkB,CAAC;KAC/D;CACF,CAAC,CAAA;AAkBF,+CAA+C;AAC/C,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAChC,MAAM,KAAK,GACT,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE;QACnF,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA;IAC9I,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;AACrE,CAAC"}
@@ -0,0 +1,14 @@
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 type { DataQualityService } from '../service.js';
8
+ /**
9
+ * Build the `data_clean` 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 defineCleanTool(service: DataQualityService): import("@deepseek-ai/dsh-tools").ToolDefinition;
14
+ //# sourceMappingURL=clean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/tools/clean.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAA6B,kBAAkB,EAAE,MAAM,eAAe,CAAA;AA0ElF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,mDA8D1D"}