dsh-statcheck 0.0.0-stage → 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 (61) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +201 -0
  3. package/README-zh.md +117 -0
  4. package/README.md +116 -2
  5. package/cordis.patch.yml +18 -0
  6. package/lib/check.d.ts +92 -0
  7. package/lib/check.d.ts.map +1 -0
  8. package/lib/check.js +250 -0
  9. package/lib/check.js.map +1 -0
  10. package/lib/config.d.ts +37 -0
  11. package/lib/config.d.ts.map +1 -0
  12. package/lib/config.js +44 -0
  13. package/lib/config.js.map +1 -0
  14. package/lib/index.d.ts +36 -0
  15. package/lib/index.d.ts.map +1 -0
  16. package/lib/index.js +50 -0
  17. package/lib/index.js.map +1 -0
  18. package/lib/math.d.ts +76 -0
  19. package/lib/math.d.ts.map +1 -0
  20. package/lib/math.js +218 -0
  21. package/lib/math.js.map +1 -0
  22. package/lib/report.d.ts +41 -0
  23. package/lib/report.d.ts.map +1 -0
  24. package/lib/report.js +91 -0
  25. package/lib/report.js.map +1 -0
  26. package/lib/runtime.d.ts +104 -0
  27. package/lib/runtime.d.ts.map +1 -0
  28. package/lib/runtime.js +235 -0
  29. package/lib/runtime.js.map +1 -0
  30. package/lib/tools/shared.d.ts +127 -0
  31. package/lib/tools/shared.d.ts.map +1 -0
  32. package/lib/tools/shared.js +61 -0
  33. package/lib/tools/shared.js.map +1 -0
  34. package/lib/tools/stat-check.d.ts +12 -0
  35. package/lib/tools/stat-check.d.ts.map +1 -0
  36. package/lib/tools/stat-check.js +83 -0
  37. package/lib/tools/stat-check.js.map +1 -0
  38. package/lib/tools/stat-recompute.d.ts +12 -0
  39. package/lib/tools/stat-recompute.d.ts.map +1 -0
  40. package/lib/tools/stat-recompute.js +82 -0
  41. package/lib/tools/stat-recompute.js.map +1 -0
  42. package/lib/tools/stat-report.d.ts +10 -0
  43. package/lib/tools/stat-report.d.ts.map +1 -0
  44. package/lib/tools/stat-report.js +66 -0
  45. package/lib/tools/stat-report.js.map +1 -0
  46. package/lib/version.d.ts +7 -0
  47. package/lib/version.d.ts.map +1 -0
  48. package/lib/version.js +7 -0
  49. package/lib/version.js.map +1 -0
  50. package/package.json +82 -4
  51. package/src/check.ts +308 -0
  52. package/src/config.ts +71 -0
  53. package/src/index.ts +75 -0
  54. package/src/math.ts +205 -0
  55. package/src/report.ts +113 -0
  56. package/src/runtime.ts +293 -0
  57. package/src/tools/shared.ts +77 -0
  58. package/src/tools/stat-check.ts +83 -0
  59. package/src/tools/stat-recompute.ts +82 -0
  60. package/src/tools/stat-report.ts +68 -0
  61. package/src/version.ts +7 -0
package/lib/runtime.js ADDED
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Runtime: text/path handling, REP evidence and records for statistical
3
+ * findings.
4
+ *
5
+ * A finding is a check on the manuscript snapshot: `pass` for a consistent
6
+ * report, `fail` for an inconsistent one, `skipped` (`parse_failed`) when no p
7
+ * value could be located. The evidence status therefore inherits the same
8
+ * honesty rules as the rest of the family.
9
+ *
10
+ * @module dsh-statcheck/runtime
11
+ */
12
+ import { mkdir, readFile, realpath, stat, writeFile } from 'node:fs/promises';
13
+ import path from 'node:path';
14
+ import { EvidenceStore, RepStoreError, stableId, validateRep, } from '@perrylink/dsh-research-core';
15
+ import { analyzeText, recomputeP, judgeP, StatInputError } from "./check.js";
16
+ import { VERSION } from "./version.js";
17
+ /** A typed failure. */
18
+ export class StatcheckError extends Error {
19
+ /** Stable code. */
20
+ code;
21
+ constructor(code, message) {
22
+ super(message);
23
+ this.name = 'StatcheckError';
24
+ this.code = code;
25
+ }
26
+ }
27
+ /** True when `candidate` is inside `root`. */
28
+ function isInside(root, candidate) {
29
+ return candidate === root || candidate.startsWith(root.endsWith(path.sep) ? root : `${root}${path.sep}`);
30
+ }
31
+ /** Media type by extension (the analyzed text keeps its source shape). */
32
+ function mediaTypeOf(name) {
33
+ const extension = name.toLowerCase().split('.').pop() ?? '';
34
+ if (extension === 'md' || extension === 'markdown')
35
+ return 'text/markdown';
36
+ if (extension === 'tex' || extension === 'latex')
37
+ return 'text/x-latex';
38
+ if (extension === 'html' || extension === 'htm')
39
+ return 'text/html';
40
+ return 'text/plain';
41
+ }
42
+ /** Map one finding to a REP check. */
43
+ export function findingToCheck(finding) {
44
+ const status = finding.status === 'consistent' ? 'pass' : finding.status === 'inconsistent' ? 'fail' : 'skipped';
45
+ return {
46
+ checkId: `chk-${finding.findingId}`,
47
+ check: 'stat-consistency',
48
+ status,
49
+ ...(status === 'skipped' ? { code: 'parse_failed' } : {}),
50
+ severity: status === 'fail' ? 'error' : status === 'skipped' ? 'warning' : 'info',
51
+ detail: `${finding.text}: ${finding.detail}`,
52
+ expected: { reportedP: finding.reported.p, statistic: finding.reported.statistic, df: [...finding.df] },
53
+ actual: { recomputedP: Number.isNaN(finding.recomputed.p) ? null : Number(finding.recomputed.p.toFixed(6)) },
54
+ };
55
+ }
56
+ /** The statcheck runtime. */
57
+ export class StatcheckRuntime {
58
+ config;
59
+ #service;
60
+ #now;
61
+ #store;
62
+ constructor(options) {
63
+ this.config = options.config;
64
+ this.#service = options.service;
65
+ this.#now = options.now ?? (() => new Date());
66
+ }
67
+ /** Current ISO timestamp. */
68
+ iso() {
69
+ return this.#now().toISOString();
70
+ }
71
+ /**
72
+ * Clamp a per-call findings cap to the configured hard cap.
73
+ * @param requested - the caller's value, when present.
74
+ * @returns a positive cap never larger than `config.maxFindings`.
75
+ */
76
+ #maxFindings(requested) {
77
+ if (requested === undefined || !Number.isSafeInteger(requested) || requested <= 0)
78
+ return this.config.maxFindings;
79
+ return Math.min(requested, this.config.maxFindings);
80
+ }
81
+ /** The evidence port. */
82
+ port() {
83
+ if (this.#service !== undefined)
84
+ return this.#service;
85
+ this.#store ??= new EvidenceStore(path.join(this.config.root, 'store'));
86
+ return this.#store;
87
+ }
88
+ /** Resolve a manuscript path inside the workspace. */
89
+ async resolvePath(input) {
90
+ if (typeof input !== 'string' || input.trim() === '')
91
+ throw new StatcheckError('INVALID_INPUT', 'path must be a non-empty string');
92
+ const root = this.config.workspaceRoot;
93
+ let realRoot;
94
+ try {
95
+ realRoot = await realpath(root);
96
+ }
97
+ catch {
98
+ throw new StatcheckError('NOT_FOUND', `workspace root does not exist: ${root}`);
99
+ }
100
+ const candidate = path.resolve(realRoot, input);
101
+ if (!isInside(realRoot, candidate))
102
+ throw new StatcheckError('PATH_ESCAPE', 'path resolves outside the workspace root');
103
+ let real;
104
+ try {
105
+ real = await realpath(candidate);
106
+ }
107
+ catch {
108
+ throw new StatcheckError('NOT_FOUND', `manuscript not found: ${input}`);
109
+ }
110
+ if (!isInside(realRoot, real))
111
+ throw new StatcheckError('PATH_ESCAPE', 'path escapes the workspace root through a symlink');
112
+ if (!(await stat(real)).isFile())
113
+ throw new StatcheckError('NOT_A_FILE', `not a regular file: ${input}`);
114
+ return { absolute: real, id: path.relative(realRoot, real).split(path.sep).join('/') };
115
+ }
116
+ /**
117
+ * Analyze text or a workspace manuscript.
118
+ * @param request - text or path plus optional caps.
119
+ * @returns findings, counts and (when persisting) the evidence id and record path.
120
+ */
121
+ async check(request) {
122
+ if ((request.text === undefined) === (request.path === undefined)) {
123
+ throw new StatcheckError('INVALID_INPUT', 'pass exactly one of text or path');
124
+ }
125
+ let text;
126
+ let source;
127
+ let mediaType = 'text/plain';
128
+ let sourceRef;
129
+ if (request.text !== undefined) {
130
+ if (request.text.length > this.config.maxChars) {
131
+ throw new StatcheckError('TOO_LARGE', `text is ${request.text.length} characters, the cap is ${this.config.maxChars}`);
132
+ }
133
+ text = request.text;
134
+ source = { kind: 'inline', id: 'inline:text', chars: text.length };
135
+ sourceRef = { kind: 'other', id: 'inline:text', retrievedAt: this.iso() };
136
+ }
137
+ else {
138
+ const resolved = await this.resolvePath(request.path);
139
+ const size = (await stat(resolved.absolute)).size;
140
+ if (size > this.config.maxChars * 4) {
141
+ throw new StatcheckError('TOO_LARGE', `manuscript is ${size} bytes, the cap is ${this.config.maxChars * 4}`);
142
+ }
143
+ text = await readFile(resolved.absolute, 'utf8');
144
+ if (text.length > this.config.maxChars) {
145
+ throw new StatcheckError('TOO_LARGE', `manuscript is ${text.length} characters, the cap is ${this.config.maxChars}`);
146
+ }
147
+ source = { kind: 'file', id: resolved.id, chars: text.length };
148
+ mediaType = mediaTypeOf(resolved.id);
149
+ sourceRef = { kind: 'file', id: resolved.id, retrievedAt: this.iso() };
150
+ }
151
+ const { findings, summary } = analyzeText(text, { maxFindings: this.#maxFindings(request.maxFindings) });
152
+ const persist = request.persist ?? this.config.persist;
153
+ if (!persist)
154
+ return { ok: true, summary, findings, source };
155
+ const port = this.port();
156
+ let evidence;
157
+ try {
158
+ const captured = await port.capture({ bytes: text, mediaType, sourceRef, capturedAt: this.iso() });
159
+ // The snapshot is immutable, so its capture time is the stable retrieval
160
+ // time: re-checking unchanged text dedupes instead of conflicting. The
161
+ // findings are part of the identity so a different cap/result is a
162
+ // different evidence item rather than an EVIDENCE_CONFLICT.
163
+ const evidenceSourceRef = {
164
+ ...sourceRef,
165
+ retrievedAt: captured.snapshot.capturedAt,
166
+ };
167
+ evidence = (await port.addEvidence({
168
+ evidenceId: stableId('ev', [
169
+ 'statcheck',
170
+ source.kind,
171
+ source.id,
172
+ captured.snapshot.snapshotId,
173
+ summary.total,
174
+ ...findings.map(finding => finding.findingId),
175
+ ]),
176
+ title: `Statistical report of ${source.id}`,
177
+ sourceRef: evidenceSourceRef,
178
+ snapshotIds: [captured.snapshot.snapshotId],
179
+ anchors: [{ snapshotId: captured.snapshot.snapshotId, kind: 'record', value: 'field:text' }],
180
+ provenance: { plugin: 'dsh-statcheck', version: VERSION, method: 'apa-stat-consistency', retrievedAt: captured.snapshot.capturedAt },
181
+ checks: findings.map(findingToCheck),
182
+ notes: `${summary.total} statistic(s): ${summary.consistent} consistent, ${summary.inconsistent} inconsistent, ${summary.unparsed} unparsed`,
183
+ })).evidence;
184
+ }
185
+ catch (error) {
186
+ if (error instanceof RepStoreError)
187
+ throw new StatcheckError('STORE_ERROR', error.message);
188
+ throw error;
189
+ }
190
+ let recordPath;
191
+ try {
192
+ const record = await port.buildRecord({ evidenceIds: [evidence.evidenceId] });
193
+ if (!validateRep(record).ok)
194
+ throw new StatcheckError('STORE_ERROR', 'refusing to write an invalid REP record');
195
+ const directory = path.join(this.config.root, 'records');
196
+ await mkdir(directory, { recursive: true });
197
+ const file = path.join(directory, `${evidence.evidenceId}.rep.json`);
198
+ await writeFile(file, `${JSON.stringify(record, null, 2)}\n`, 'utf8');
199
+ recordPath = file;
200
+ }
201
+ catch (error) {
202
+ if (error instanceof StatcheckError)
203
+ throw error;
204
+ throw new StatcheckError('STORE_ERROR', `could not write the REP record: ${error.message}`);
205
+ }
206
+ return { ok: true, summary, findings, source, evidenceId: evidence.evidenceId, ...(recordPath === undefined ? {} : { recordPath }) };
207
+ }
208
+ /**
209
+ * Recompute one statistic and optionally judge a reported p.
210
+ * @param input - statistic kind, value, df and optional reported p string.
211
+ * @returns the recomputed p and, when a p was given, the judgment.
212
+ */
213
+ recompute(input) {
214
+ let p;
215
+ try {
216
+ p = recomputeP({ statistic: input.statistic, value: input.value, df: input.df });
217
+ }
218
+ catch (error) {
219
+ if (error instanceof StatInputError)
220
+ throw new StatcheckError(error.code, error.message);
221
+ throw error;
222
+ }
223
+ if (input.p === undefined)
224
+ return { p };
225
+ const parsed = /^(<|>|=|≤|≥)?\s*(\.\d+|\d+\.?\d*)$/u.exec(input.p.trim());
226
+ if (parsed === null)
227
+ throw new StatcheckError('INVALID_INPUT', `cannot parse the reported p: ${input.p}`);
228
+ const kind = parsed[1] === '<' || parsed[1] === '≤' ? 'less' : parsed[1] === '>' || parsed[1] === '≥' ? 'greater' : 'equal';
229
+ const judgment = judgeP({ pRaw: parsed[2], pKind: kind, recomputed: p });
230
+ return { p, judgment };
231
+ }
232
+ }
233
+ /** Re-export the math errors for tools. */
234
+ export { StatInputError };
235
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 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AE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;QACzE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAA;IACxB,CAAC;CACF;AAED,2CAA2C;AAC3C,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Tool schema fragments for dsh-statcheck.
3
+ * @module dsh-statcheck/tools/shared
4
+ */
5
+ /** The failure branch. */
6
+ export declare const ERROR_SCHEMA: {
7
+ readonly type: "object";
8
+ readonly additionalProperties: false;
9
+ readonly properties: {
10
+ readonly code: {
11
+ readonly type: "string";
12
+ readonly required: true;
13
+ };
14
+ readonly message: {
15
+ readonly type: "string";
16
+ readonly required: true;
17
+ };
18
+ };
19
+ };
20
+ /** One finding. */
21
+ export declare const FINDING_SCHEMA: {
22
+ readonly type: "object";
23
+ readonly additionalProperties: false;
24
+ readonly properties: {
25
+ readonly findingId: {
26
+ readonly type: "string";
27
+ readonly required: true;
28
+ };
29
+ readonly statistic: {
30
+ readonly type: "string";
31
+ readonly required: true;
32
+ };
33
+ readonly text: {
34
+ readonly type: "string";
35
+ readonly required: true;
36
+ };
37
+ readonly charStart: {
38
+ readonly type: "integer";
39
+ readonly required: true;
40
+ };
41
+ readonly charEnd: {
42
+ readonly type: "integer";
43
+ readonly required: true;
44
+ };
45
+ readonly df: {
46
+ readonly type: "array";
47
+ readonly items: {
48
+ readonly type: "number";
49
+ };
50
+ };
51
+ readonly status: {
52
+ readonly type: "string";
53
+ readonly required: true;
54
+ };
55
+ readonly detail: {
56
+ readonly type: "string";
57
+ readonly required: true;
58
+ };
59
+ readonly severity: {
60
+ readonly type: "string";
61
+ readonly required: true;
62
+ };
63
+ readonly issue: {
64
+ readonly type: "string";
65
+ };
66
+ readonly reported: {
67
+ readonly type: "json";
68
+ };
69
+ readonly recomputed: {
70
+ readonly type: "json";
71
+ };
72
+ };
73
+ };
74
+ /** The summary counters. */
75
+ export declare const SUMMARY_SCHEMA: {
76
+ readonly type: "object";
77
+ readonly additionalProperties: false;
78
+ readonly properties: {
79
+ readonly total: {
80
+ readonly type: "integer";
81
+ readonly required: true;
82
+ };
83
+ readonly consistent: {
84
+ readonly type: "integer";
85
+ readonly required: true;
86
+ };
87
+ readonly inconsistent: {
88
+ readonly type: "integer";
89
+ readonly required: true;
90
+ };
91
+ readonly unparsed: {
92
+ readonly type: "integer";
93
+ readonly required: true;
94
+ };
95
+ };
96
+ };
97
+ /** Project one finding into lossless JSON. */
98
+ export declare function plainFinding(finding: {
99
+ findingId: string;
100
+ statistic: string;
101
+ text: string;
102
+ charStart: number;
103
+ charEnd: number;
104
+ df: readonly number[];
105
+ status: string;
106
+ detail: string;
107
+ severity: string;
108
+ issue?: string;
109
+ reported: Record<string, unknown>;
110
+ recomputed: {
111
+ p: number;
112
+ };
113
+ }): {
114
+ reported: never;
115
+ recomputed: never;
116
+ issue?: string;
117
+ findingId: string;
118
+ statistic: string;
119
+ text: string;
120
+ charStart: number;
121
+ charEnd: number;
122
+ df: number[];
123
+ status: string;
124
+ detail: string;
125
+ severity: string;
126
+ };
127
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAA0B;AAC1B,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAOf,CAAA;AAEV,mBAAmB;AACnB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBjB,CAAA;AAEV,4BAA4B;AAC5B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;CASjB,CAAA;AAEV,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,SAAS,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,UAAU,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1B;cAY4I,KAAK;gBACvD,KAAK;;;;;;;;;;;EAE/F"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Tool schema fragments for dsh-statcheck.
3
+ * @module dsh-statcheck/tools/shared
4
+ */
5
+ /** The failure branch. */
6
+ export const ERROR_SCHEMA = {
7
+ type: 'object',
8
+ additionalProperties: false,
9
+ properties: {
10
+ code: { type: 'string', required: true },
11
+ message: { type: 'string', required: true },
12
+ },
13
+ };
14
+ /** One finding. */
15
+ export const FINDING_SCHEMA = {
16
+ type: 'object',
17
+ additionalProperties: false,
18
+ properties: {
19
+ findingId: { type: 'string', required: true },
20
+ statistic: { type: 'string', required: true },
21
+ text: { type: 'string', required: true },
22
+ charStart: { type: 'integer', required: true },
23
+ charEnd: { type: 'integer', required: true },
24
+ df: { type: 'array', items: { type: 'number' } },
25
+ status: { type: 'string', required: true },
26
+ detail: { type: 'string', required: true },
27
+ severity: { type: 'string', required: true },
28
+ issue: { type: 'string' },
29
+ reported: { type: 'json' },
30
+ recomputed: { type: 'json' },
31
+ },
32
+ };
33
+ /** The summary counters. */
34
+ export const SUMMARY_SCHEMA = {
35
+ type: 'object',
36
+ additionalProperties: false,
37
+ properties: {
38
+ total: { type: 'integer', required: true },
39
+ consistent: { type: 'integer', required: true },
40
+ inconsistent: { type: 'integer', required: true },
41
+ unparsed: { type: 'integer', required: true },
42
+ },
43
+ };
44
+ /** Project one finding into lossless JSON. */
45
+ export function plainFinding(finding) {
46
+ return {
47
+ findingId: finding.findingId,
48
+ statistic: finding.statistic,
49
+ text: finding.text,
50
+ charStart: finding.charStart,
51
+ charEnd: finding.charEnd,
52
+ df: [...finding.df],
53
+ status: finding.status,
54
+ detail: finding.detail,
55
+ severity: finding.severity,
56
+ ...(finding.issue === undefined ? {} : { issue: finding.issue }),
57
+ reported: { ...finding.reported, ...(finding.reported['ci'] === undefined ? {} : { ci: [...finding.reported['ci']] }) },
58
+ recomputed: { p: Number.isNaN(finding.recomputed.p) ? null : finding.recomputed.p },
59
+ };
60
+ }
61
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAA0B;AAC1B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5C;CACO,CAAA;AAEV,mBAAmB;AACnB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAA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O,CAAC,EAAE,CAAC;QACnB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QAChE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc,CAAC,EAAE,CAAC,EAAW;QAC9I,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAW;KAC7F,CAAA;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `stat_check` — recompute reported statistics in a manuscript.
3
+ * @module dsh-statcheck/tools/stat-check
4
+ */
5
+ import { type StatcheckRuntime } from '../runtime.ts';
6
+ /**
7
+ * Build the `stat_check` tool.
8
+ * @param runtime - the statcheck runtime.
9
+ * @returns the tool definition.
10
+ */
11
+ export declare function makeStatCheckTool(runtime: StatcheckRuntime): import("@deepseek-ai/dsh-tools").ToolDefinition;
12
+ //# sourceMappingURL=stat-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat-check.d.ts","sourceRoot":"","sources":["../../src/tools/stat-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAiBrE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,mDAsD1D"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * `stat_check` — recompute reported statistics in a manuscript.
3
+ * @module dsh-statcheck/tools/stat-check
4
+ */
5
+ import { defineTool } from '@deepseek-ai/dsh-tools';
6
+ import { StatcheckError } from "../runtime.js";
7
+ import { ERROR_SCHEMA, FINDING_SCHEMA, SUMMARY_SCHEMA, plainFinding } from "./shared.js";
8
+ const OUTPUT_SCHEMA = {
9
+ type: 'object',
10
+ additionalProperties: false,
11
+ properties: {
12
+ ok: { type: 'boolean', required: true },
13
+ summary: SUMMARY_SCHEMA,
14
+ findings: { type: 'array', items: FINDING_SCHEMA },
15
+ source: { type: 'json' },
16
+ evidenceId: { type: 'string' },
17
+ recordPath: { type: 'string' },
18
+ error: ERROR_SCHEMA,
19
+ },
20
+ };
21
+ /**
22
+ * Build the `stat_check` tool.
23
+ * @param runtime - the statcheck runtime.
24
+ * @returns the tool definition.
25
+ */
26
+ export function makeStatCheckTool(runtime) {
27
+ return defineTool({
28
+ name: 'stat_check',
29
+ description: [
30
+ 'Recompute the p values reported in a manuscript and flag self-inconsistent statistics (dsh-statcheck).',
31
+ '',
32
+ 'Parses APA-style reports: t(df), F(df1, df2), χ²(df), r(df), z, each with a nearby p value (`p = .018`, `p < .001`) and an optional 95% CI. The p value is recomputed from the reported statistic only — no data is re-analysed, no model is judged.',
33
+ '',
34
+ 'Flags mean "the reported p does not follow from the reported statistic", with both numbers and the character range shown. They do NOT imply misconduct and must be reviewed by a human. Scanned/PDF text is out of scope: extract text first (dsh-doc-anchor) and pass `text` or a `.txt`/`.md`/`.tex` path.',
35
+ ].join('\n'),
36
+ parameters: {
37
+ text: { type: 'string', description: 'Manuscript text to analyze (mutually exclusive with path).' },
38
+ path: { type: 'string', description: 'Workspace-relative manuscript path (.txt/.md/.tex/.html; must stay inside the workspace).' },
39
+ persist: { type: 'boolean', description: 'Store the analyzed text as a REP snapshot + record (default true).' },
40
+ maxFindings: { type: 'integer', description: 'Findings cap for this call.' },
41
+ },
42
+ output: {
43
+ schema: OUTPUT_SCHEMA,
44
+ render: (_args, value) => {
45
+ const result = value;
46
+ if (!result.ok)
47
+ return [{ type: 'text', text: `stat_check failed (${result.error.code}): ${result.error.message}` }];
48
+ const lines = [
49
+ `stat_check: ${result.summary.total} statistic(s) — ${result.summary.consistent} consistent, ${result.summary.inconsistent} inconsistent, ${result.summary.unparsed} unparsed`,
50
+ ];
51
+ for (const finding of result.findings.filter(item => item.status === 'inconsistent').slice(0, 20)) {
52
+ lines.push(` [inconsistent] ${finding.text} — ${finding.detail} (chars ${finding.charStart}-${finding.charStart + finding.text.length})`);
53
+ }
54
+ if (result.summary.inconsistent > 0) {
55
+ lines.push(' these findings are candidates for human review, not a conclusion about the authors');
56
+ }
57
+ if (result.evidenceId !== undefined)
58
+ lines.push(`evidence ${result.evidenceId}`);
59
+ return [{ type: 'text', text: lines.join('\n') }];
60
+ },
61
+ },
62
+ async execute(args) {
63
+ const request = args;
64
+ try {
65
+ const result = await runtime.check(request);
66
+ return {
67
+ ok: true,
68
+ summary: { ...result.summary },
69
+ findings: result.findings.map(plainFinding),
70
+ source: { ...result.source },
71
+ ...(result.evidenceId === undefined ? {} : { evidenceId: result.evidenceId }),
72
+ ...(result.recordPath === undefined ? {} : { recordPath: result.recordPath }),
73
+ };
74
+ }
75
+ catch (error) {
76
+ if (error instanceof StatcheckError)
77
+ return { ok: false, error: { code: error.code, message: error.message } };
78
+ throw error;
79
+ }
80
+ },
81
+ });
82
+ }
83
+ //# sourceMappingURL=stat-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat-check.js","sourceRoot":"","sources":["../../src/tools/stat-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAyB,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,cAAc,E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OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBAC3C,OAAO;oBACL,EAAE,EAAE,IAAa;oBACjB,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE;oBAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;oBAC3C,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE;oBAC5B,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;oBAC7E,GAAG,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;iBAC9E,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,cAAc;oBAAE,OAAO,EAAE,EAAE,EAAE,KAAc,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAA;gBACvH,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `stat_recompute` — one statistic in, the recomputed p value out.
3
+ * @module dsh-statcheck/tools/stat-recompute
4
+ */
5
+ import { type StatcheckRuntime } from '../runtime.ts';
6
+ /**
7
+ * Build the `stat_recompute` tool.
8
+ * @param runtime - the statcheck runtime.
9
+ * @returns the tool definition.
10
+ */
11
+ export declare function makeStatRecomputeTool(runtime: StatcheckRuntime): import("@deepseek-ai/dsh-tools").ToolDefinition;
12
+ //# sourceMappingURL=stat-recompute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat-recompute.d.ts","sourceRoot":"","sources":["../../src/tools/stat-recompute.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAiBrE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,mDAqD9D"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * `stat_recompute` — one statistic in, the recomputed p value out.
3
+ * @module dsh-statcheck/tools/stat-recompute
4
+ */
5
+ import { defineTool } from '@deepseek-ai/dsh-tools';
6
+ import { StatcheckError } from "../runtime.js";
7
+ import { ERROR_SCHEMA } from "./shared.js";
8
+ const OUTPUT_SCHEMA = {
9
+ type: 'object',
10
+ additionalProperties: false,
11
+ properties: {
12
+ ok: { type: 'boolean', required: true },
13
+ statistic: { type: 'string' },
14
+ value: { type: 'number' },
15
+ df: { type: 'array', items: { type: 'number' } },
16
+ p: { type: 'number' },
17
+ judgment: { type: 'json' },
18
+ error: ERROR_SCHEMA,
19
+ },
20
+ };
21
+ /**
22
+ * Build the `stat_recompute` tool.
23
+ * @param runtime - the statcheck runtime.
24
+ * @returns the tool definition.
25
+ */
26
+ export function makeStatRecomputeTool(runtime) {
27
+ return defineTool({
28
+ name: 'stat_recompute',
29
+ description: [
30
+ 'Recompute a p value from a single reported statistic (dsh-statcheck).',
31
+ '',
32
+ 't and r are two-tailed; F and χ² are upper-tail; z is two-tailed. Degrees of freedom are required (t: 1, F: 2, χ²: 1, r: 1, z: 0). Pass `p` as written (e.g. ".018" or "<.001") to also get a consistency judgment with the same rounding rule used by stat_check.',
33
+ '',
34
+ 'This is arithmetic, not inference: it does not re-analyse data and cannot tell whether the reported statistic itself is appropriate.',
35
+ ].join('\n'),
36
+ parameters: {
37
+ statistic: { type: 'string', enum: ['t', 'F', 'chi2', 'r', 'z'], description: 'Statistic family.' },
38
+ value: { type: 'number', required: true, description: 'The reported statistic.' },
39
+ df: { type: 'array', items: { type: 'number' }, description: 'Degrees of freedom as reported (empty for z).' },
40
+ p: { type: 'string', description: 'The p value as reported (".018", "<.001", "= .05").' },
41
+ },
42
+ output: {
43
+ schema: OUTPUT_SCHEMA,
44
+ render: (_args, value) => {
45
+ const result = value;
46
+ if (!result.ok)
47
+ return [{ type: 'text', text: `stat_recompute failed (${result.error.code}): ${result.error.message}` }];
48
+ const lines = [`stat_recompute: ${result.statistic} = ${result.value}${result.df.length === 0 ? '' : `, df = ${result.df.join(', ')}`} → p = ${result.p.toFixed(6)}`];
49
+ if (result.judgment !== undefined)
50
+ lines.push(` ${result.judgment.status}${result.judgment.issue === undefined ? '' : ` (${result.judgment.issue})`}: ${result.judgment.detail}`);
51
+ return [{ type: 'text', text: lines.join('\n') }];
52
+ },
53
+ },
54
+ async execute(args) {
55
+ const request = args;
56
+ try {
57
+ const result = runtime.recompute({
58
+ statistic: request.statistic,
59
+ value: request.value,
60
+ df: request.df ?? [],
61
+ ...(request.p === undefined ? {} : { p: request.p }),
62
+ });
63
+ return {
64
+ ok: true,
65
+ statistic: request.statistic,
66
+ value: request.value,
67
+ df: [...(request.df ?? [])],
68
+ p: result.p,
69
+ ...(result.judgment === undefined
70
+ ? {}
71
+ : { judgment: { status: result.judgment.status, ...(result.judgment.issue === undefined ? {} : { issue: result.judgment.issue }), detail: result.judgment.detail } }),
72
+ };
73
+ }
74
+ catch (error) {
75
+ if (error instanceof StatcheckError)
76
+ return { ok: false, error: { code: error.code, message: error.message } };
77
+ throw error;
78
+ }
79
+ },
80
+ });
81
+ }
82
+ //# sourceMappingURL=stat-recompute.js.map