@lucern/confidence 0.3.0-alpha.17 → 0.3.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/v1/index.js CHANGED
@@ -1125,9 +1125,6 @@ function generateContractId() {
1125
1125
  }
1126
1126
  return `contract-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
1127
1127
  }
1128
- function isRecord(value) {
1129
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1130
- }
1131
1128
  function deriveContractStatus(result, currentStatus) {
1132
1129
  if (currentStatus === "archived") {
1133
1130
  return currentStatus;
@@ -1269,17 +1266,18 @@ function pickFiniteNumber(config, keys) {
1269
1266
  return void 0;
1270
1267
  }
1271
1268
  function getEvaluatorInputRecord(inputData, nestedKey) {
1272
- if (!isRecord(inputData)) {
1269
+ if (!inputData || typeof inputData !== "object") {
1273
1270
  return {};
1274
1271
  }
1275
- const nested = inputData[nestedKey];
1276
- if (isRecord(nested)) {
1272
+ const root = inputData;
1273
+ const nested = root[nestedKey];
1274
+ if (nested && typeof nested === "object") {
1277
1275
  return nested;
1278
1276
  }
1279
- return inputData;
1277
+ return root;
1280
1278
  }
1281
1279
  function parseEvidentialEvaluatorConfig(value) {
1282
- if (!isRecord(value)) {
1280
+ if (!value || typeof value !== "object") {
1283
1281
  throw new Error(
1284
1282
  "Evidential contracts require condition.evaluatorConfig with metric/operator/threshold."
1285
1283
  );
@@ -1297,7 +1295,7 @@ function parseEvidentialEvaluatorConfig(value) {
1297
1295
  if (typeof threshold !== "number" || !Number.isFinite(threshold)) {
1298
1296
  throw new Error("Evidential contracts require a numeric threshold.");
1299
1297
  }
1300
- const actionParams = isRecord(config.actionParams) ? config.actionParams : void 0;
1298
+ const actionParams = config.actionParams && typeof config.actionParams === "object" && config.actionParams !== null ? config.actionParams : void 0;
1301
1299
  return {
1302
1300
  metric,
1303
1301
  operator,
@@ -1346,7 +1344,7 @@ function buildEvidentialRationale(args) {
1346
1344
  return `${clause}; comparison ${args.comparisonSatisfied ? "passed" : "failed"}, resulting in ${args.result}.`;
1347
1345
  }
1348
1346
  function parseMetricCheckerConfig(value) {
1349
- if (!isRecord(value)) {
1347
+ if (!value || typeof value !== "object") {
1350
1348
  throw new Error(
1351
1349
  "metric_checker requires condition.evaluatorConfig with observedValue/operator/threshold."
1352
1350
  );
@@ -1363,7 +1361,7 @@ function parseMetricCheckerConfig(value) {
1363
1361
  };
1364
1362
  }
1365
1363
  function parseReferenceCheckCounterConfig(value) {
1366
- if (!isRecord(value)) {
1364
+ if (!value || typeof value !== "object") {
1367
1365
  throw new Error(
1368
1366
  "reference_check_counter requires condition.evaluatorConfig with tag/operator/threshold."
1369
1367
  );
@@ -1386,7 +1384,7 @@ function parseReferenceCheckCounterConfig(value) {
1386
1384
  };
1387
1385
  }
1388
1386
  function parseTemporalDeadlineConfig(value) {
1389
- if (!isRecord(value)) {
1387
+ if (!value || typeof value !== "object") {
1390
1388
  return {};
1391
1389
  }
1392
1390
  const config = value;
@@ -1400,7 +1398,7 @@ function parseTemporalDeadlineConfig(value) {
1400
1398
  };
1401
1399
  }
1402
1400
  function parseMarketIndexComparatorConfig(value) {
1403
- if (!isRecord(value)) {
1401
+ if (!value || typeof value !== "object") {
1404
1402
  throw new Error(
1405
1403
  "market_index_comparator requires condition.evaluatorConfig with subjectValue/benchmarkValue/operator/threshold."
1406
1404
  );