@gobing-ai/ts-ai-runner 0.5.17 → 0.5.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/decision/validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAoBxC,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAoCnG;AAUD,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CA8B3F"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/decision/validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAuBxC,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAoCnG;AAUD,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAqC3F"}
@@ -1,4 +1,6 @@
1
1
  import { DecisionBackendError, DecisionRequestError } from './errors.js';
2
+ /** Probability-mass tolerance: |total - 1| at or below this counts as a normalized distribution. */
3
+ const DISTRIBUTION_MASS_TOLERANCE = 1e-6;
2
4
  function record(value) {
3
5
  return value !== null && typeof value === 'object' && !Array.isArray(value);
4
6
  }
@@ -88,5 +90,10 @@ export function validateAnswers(questions, answers) {
88
90
  !Object.values(answer.legend).every(desc)) {
89
91
  fail(name);
90
92
  }
93
+ // Placed after the per-entry checks so their errors keep precedence; every entry is a
94
+ // bounded number here. Inclusive at exactly 1e-6.
95
+ const total = Object.values(answer.probabilities).reduce((sum, p) => sum + p, 0);
96
+ if (Math.abs(total - 1) > DISTRIBUTION_MASS_TOLERANCE)
97
+ fail(name);
91
98
  }
92
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/ts-ai-runner",
3
- "version": "0.5.17",
3
+ "version": "0.5.18",
4
4
  "description": "@gobing-ai/ts-ai-runner — Coding-agent shims, detection, doctor checks, and prompt execution.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -47,13 +47,13 @@
47
47
  "release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-ai-runner-v<version> && git push --tags' && exit 1"
48
48
  },
49
49
  "dependencies": {
50
- "@gobing-ai/ts-infra": "^0.5.17",
51
- "@gobing-ai/ts-runtime": "^0.5.17",
50
+ "@gobing-ai/ts-infra": "^0.5.18",
51
+ "@gobing-ai/ts-runtime": "^0.5.18",
52
52
  "@typesafe-ai/sdk": "0.6.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/bun": "1.3.14",
56
- "@gobing-ai/ts-db": "^0.5.17"
56
+ "@gobing-ai/ts-db": "^0.5.18"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"
@@ -1,6 +1,9 @@
1
1
  import { DecisionBackendError, DecisionRequestError } from './errors';
2
2
  import type { Question } from './types';
3
3
 
4
+ /** Probability-mass tolerance: |total - 1| at or below this counts as a normalized distribution. */
5
+ const DISTRIBUTION_MASS_TOLERANCE = 1e-6;
6
+
4
7
  function record(value: unknown): value is Record<string, unknown> {
5
8
  return value !== null && typeof value === 'object' && !Array.isArray(value);
6
9
  }
@@ -96,5 +99,12 @@ export function validateAnswers(questions: Record<string, Question>, answers: un
96
99
  ) {
97
100
  fail(name);
98
101
  }
102
+ // Placed after the per-entry checks so their errors keep precedence; every entry is a
103
+ // bounded number here. Inclusive at exactly 1e-6.
104
+ const total = Object.values(answer.probabilities as Record<string, unknown>).reduce<number>(
105
+ (sum, p) => sum + (p as number),
106
+ 0,
107
+ );
108
+ if (Math.abs(total - 1) > DISTRIBUTION_MASS_TOLERANCE) fail(name);
99
109
  }
100
110
  }