@sublang/slc 0.17.0 → 0.18.1
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/README.md +15 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -1
- package/dist/app.js.map +1 -1
- package/dist/config-file.d.ts +1 -0
- package/dist/config-file.d.ts.map +1 -1
- package/dist/config-file.js +4 -0
- package/dist/config-file.js.map +1 -1
- package/dist/reviewing-agent.d.ts.map +1 -1
- package/dist/reviewing-agent.js +13 -12
- package/dist/reviewing-agent.js.map +1 -1
- package/dist/slc.config.template.yaml +2 -1
- package/dist/verify-coverage.d.ts +5 -0
- package/dist/verify-coverage.d.ts.map +1 -1
- package/dist/verify-coverage.js +123 -27
- package/dist/verify-coverage.js.map +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +221 -73
- package/dist/verify.js.map +1 -1
- package/package.json +1 -1
package/dist/verify-coverage.js
CHANGED
|
@@ -33,17 +33,20 @@ export function resolveCoverageBudget(value = {}) {
|
|
|
33
33
|
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
34
34
|
throw new TypeError('coverage must be an object');
|
|
35
35
|
for (const key of Reflect.ownKeys(value))
|
|
36
|
-
if (key !== 'maxInvocations' &&
|
|
36
|
+
if (key !== 'maxInvocations' &&
|
|
37
|
+
key !== 'maxAttempts' &&
|
|
38
|
+
key !== 'maxDurationMs')
|
|
37
39
|
throw new TypeError(`Unknown coverage budget key: ${String(key)}`);
|
|
38
|
-
const { maxInvocations = 8, maxAttempts = 64 } = value;
|
|
40
|
+
const { maxInvocations = 8, maxAttempts = 64, maxDurationMs = 300_000, } = value;
|
|
39
41
|
for (const [key, limit, cap] of [
|
|
40
42
|
['maxInvocations', maxInvocations, 64],
|
|
41
43
|
['maxAttempts', maxAttempts, 1024],
|
|
44
|
+
['maxDurationMs', maxDurationMs, 1_800_000],
|
|
42
45
|
]) {
|
|
43
46
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > cap)
|
|
44
47
|
throw new RangeError(`coverage.${key} must be an integer from 1 to ${cap}`);
|
|
45
48
|
}
|
|
46
|
-
return Object.freeze({ maxInvocations, maxAttempts });
|
|
49
|
+
return Object.freeze({ maxInvocations, maxAttempts, maxDurationMs });
|
|
47
50
|
}
|
|
48
51
|
// Each check owns its resources, including concurrent checks and async actor
|
|
49
52
|
// callbacks. No current-run variable is shared between invocations.
|
|
@@ -1178,7 +1181,6 @@ const MAX_SCRIPT_EXIT_STATUSES = 8;
|
|
|
1178
1181
|
const PROBES_PER_TIMEOUT_MILLISECOND = 50;
|
|
1179
1182
|
const COVERAGE_TIMEOUT_MARGIN_MS = 5_000;
|
|
1180
1183
|
const MIN_COVERAGE_TEST_TIMEOUT_MS = 10_000;
|
|
1181
|
-
const MAX_COVERAGE_TEST_TIMEOUT_MS = 300_000;
|
|
1182
1184
|
function minedLiterals(fn) {
|
|
1183
1185
|
let source;
|
|
1184
1186
|
try {
|
|
@@ -1244,9 +1246,26 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1244
1246
|
prototype: Object.getPrototypeOf(base),
|
|
1245
1247
|
descriptors: Object.getOwnPropertyDescriptors(base),
|
|
1246
1248
|
};
|
|
1249
|
+
const descriptors = shape.descriptors;
|
|
1250
|
+
if ((shape.prototype === Object.prototype || shape.prototype === null) &&
|
|
1251
|
+
Reflect.ownKeys(descriptors).every((key) => {
|
|
1252
|
+
const descriptor = Reflect.get(descriptors, key);
|
|
1253
|
+
return ('value' in descriptor &&
|
|
1254
|
+
descriptor.enumerable === true &&
|
|
1255
|
+
descriptor.configurable === true &&
|
|
1256
|
+
descriptor.writable === true);
|
|
1257
|
+
})) {
|
|
1258
|
+
// Define once from descriptors: never read seed getters or assign an
|
|
1259
|
+
// own __proto__ through a setter. Spread only this private data seed.
|
|
1260
|
+
shape.data = Object.create(Object.prototype, descriptors);
|
|
1261
|
+
}
|
|
1247
1262
|
bases.set(base, shape);
|
|
1248
1263
|
}
|
|
1249
|
-
const copy =
|
|
1264
|
+
const copy = shape.data === undefined
|
|
1265
|
+
? Object.create(shape.prototype, shape.descriptors)
|
|
1266
|
+
: { ...shape.data };
|
|
1267
|
+
if (shape.data !== undefined && shape.prototype === null)
|
|
1268
|
+
Object.setPrototypeOf(copy, null);
|
|
1250
1269
|
return Object.assign(copy, assigned);
|
|
1251
1270
|
};
|
|
1252
1271
|
// Guard-source literals first: the likeliest matches are tried earliest.
|
|
@@ -1259,6 +1278,7 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1259
1278
|
? Object.getOwnPropertyDescriptors(options.initialContext ?? {})
|
|
1260
1279
|
: undefined;
|
|
1261
1280
|
let reachedValues = 0;
|
|
1281
|
+
const reachedCandidates = [];
|
|
1262
1282
|
const declaredValues = new Map();
|
|
1263
1283
|
const declaredDistinct = new Set();
|
|
1264
1284
|
const noteContextRead = (field, declaredField) => {
|
|
@@ -1294,13 +1314,14 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1294
1314
|
typeof value === 'string' ||
|
|
1295
1315
|
typeof value === 'boolean' ||
|
|
1296
1316
|
(typeof value === 'number' && Number.isFinite(value))) ||
|
|
1297
|
-
values.some((candidate) => Object.is(candidate, value))
|
|
1317
|
+
values.some((candidate) => Object.is(candidate, value)) ||
|
|
1318
|
+
reachedCandidates.some((candidate) => Object.is(candidate, value)))
|
|
1298
1319
|
return;
|
|
1299
1320
|
reachedValues++;
|
|
1300
|
-
|
|
1321
|
+
reachedCandidates.push(value);
|
|
1301
1322
|
};
|
|
1302
|
-
function* candidateValues(key, hasBaseline, baseline) {
|
|
1303
|
-
if (hasBaseline)
|
|
1323
|
+
function* candidateValues(key, hasBaseline, baseline, deferBaseline = false) {
|
|
1324
|
+
if (hasBaseline && !deferBaseline)
|
|
1304
1325
|
yield baseline;
|
|
1305
1326
|
const guided = key.startsWith('o:')
|
|
1306
1327
|
? declaredValues.get(key.slice(2))
|
|
@@ -1310,14 +1331,32 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1310
1331
|
if (guided[index] !== baseline)
|
|
1311
1332
|
yield guided[index];
|
|
1312
1333
|
}
|
|
1334
|
+
if (hasBaseline && deferBaseline)
|
|
1335
|
+
yield baseline;
|
|
1313
1336
|
return;
|
|
1314
1337
|
}
|
|
1315
|
-
// A failed candidate can reveal a fixed-context value needed by
|
|
1316
|
-
// field.
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1338
|
+
// A deeper failed candidate can reveal a fixed-context value needed by
|
|
1339
|
+
// this field. On every resume, try new bounded hints before the static tail.
|
|
1340
|
+
// Admission keeps the two pools disjoint; Object.is retains signed zero.
|
|
1341
|
+
const triedReached = [];
|
|
1342
|
+
let index = 0;
|
|
1343
|
+
while (true) {
|
|
1344
|
+
const hint = reachedCandidates.findIndex((value) => (!hasBaseline || value !== baseline) &&
|
|
1345
|
+
!triedReached.some((tried) => Object.is(tried, value)));
|
|
1346
|
+
if (hint !== -1) {
|
|
1347
|
+
const value = reachedCandidates[hint];
|
|
1348
|
+
triedReached.push(value);
|
|
1349
|
+
yield value;
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
if (index === values.length)
|
|
1353
|
+
break;
|
|
1354
|
+
const value = values[index++];
|
|
1355
|
+
if (!hasBaseline || value !== baseline)
|
|
1356
|
+
yield value;
|
|
1320
1357
|
}
|
|
1358
|
+
if (hasBaseline && deferBaseline)
|
|
1359
|
+
yield baseline;
|
|
1321
1360
|
}
|
|
1322
1361
|
const probeBudget = options.probeBudget ?? { probes: 0 };
|
|
1323
1362
|
const discovered = new Map();
|
|
@@ -1431,13 +1470,18 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1431
1470
|
'value' in descriptor &&
|
|
1432
1471
|
!discoverShape &&
|
|
1433
1472
|
shapeTag === undefined) {
|
|
1473
|
+
if (tag === 'o:' &&
|
|
1474
|
+
options.declaredResultFields?.includes(prop) &&
|
|
1475
|
+
!Object.hasOwn(assigned, prop))
|
|
1476
|
+
declaredField = prop;
|
|
1434
1477
|
const payload = payloads.find((item) => item.tag === tag);
|
|
1435
|
-
|
|
1478
|
+
// An assigned field cannot guide another choice, but reading it
|
|
1479
|
+
// must not erase an earlier unresolved descriptor-value hint.
|
|
1480
|
+
if ((varyExisting ||
|
|
1436
1481
|
payload?.varyExisting === true ||
|
|
1437
|
-
payload?.shapeFields?.includes(prop))
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
: `${tag}${prop}`;
|
|
1482
|
+
payload?.shapeFields?.includes(prop)) &&
|
|
1483
|
+
!Object.hasOwn(assigned, prop))
|
|
1484
|
+
descriptorRead = `${tag}${prop}`;
|
|
1441
1485
|
}
|
|
1442
1486
|
return descriptor;
|
|
1443
1487
|
},
|
|
@@ -1517,9 +1561,31 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1517
1561
|
if (!enumerated.has(payload.tag))
|
|
1518
1562
|
continue;
|
|
1519
1563
|
shapeTag = payload.tag;
|
|
1564
|
+
// Overriding existing default data keys preserves their enumerable set.
|
|
1565
|
+
// New keys can encounter inherited setters; keep the original trials
|
|
1566
|
+
// for those, event-level merges and descriptor-backed seeds.
|
|
1567
|
+
const data = bases.get(payload.base)?.data;
|
|
1568
|
+
const assigned = assignment.payloads[payload.tag] ?? {};
|
|
1569
|
+
const unpaddedWidth = payload.eventField !== undefined &&
|
|
1570
|
+
data !== undefined &&
|
|
1571
|
+
!Object.hasOwn(assigned, '__proto__') &&
|
|
1572
|
+
Object.keys(assigned).every((key) => Object.hasOwn(data, key))
|
|
1573
|
+
? Object.keys(data).length
|
|
1574
|
+
: undefined;
|
|
1575
|
+
let previousWidth;
|
|
1520
1576
|
for (shapeWidth = 1; shapeWidth <= 4; shapeWidth++) {
|
|
1577
|
+
coverageCheckpoint();
|
|
1521
1578
|
if (++probeBudget.probes > MAX_PROBES)
|
|
1522
1579
|
return [...reads];
|
|
1580
|
+
// Keep every logical trial's charge, but evaluate an identical
|
|
1581
|
+
// guidance-only padding shape once within this payload/read pass.
|
|
1582
|
+
// The first selected-shape trace remains separate from trace() above.
|
|
1583
|
+
const width = unpaddedWidth === undefined
|
|
1584
|
+
? undefined
|
|
1585
|
+
: Math.max(unpaddedWidth, shapeWidth);
|
|
1586
|
+
if (width !== undefined && width === previousWidth)
|
|
1587
|
+
continue;
|
|
1588
|
+
previousWidth = width;
|
|
1523
1589
|
trace();
|
|
1524
1590
|
}
|
|
1525
1591
|
}
|
|
@@ -1571,7 +1637,9 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1571
1637
|
};
|
|
1572
1638
|
});
|
|
1573
1639
|
}
|
|
1574
|
-
|
|
1640
|
+
function* search(assignment, depth, deferred) {
|
|
1641
|
+
// Resume before evaluation so the other traversal shares every probe charge.
|
|
1642
|
+
yield;
|
|
1575
1643
|
coverageCheckpoint();
|
|
1576
1644
|
if (probeBudget.probes > MAX_PROBES)
|
|
1577
1645
|
return undefined;
|
|
@@ -1603,7 +1671,9 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1603
1671
|
const baseline = hasBaseline
|
|
1604
1672
|
? base[field]
|
|
1605
1673
|
: undefined;
|
|
1606
|
-
for (const value of candidateValues(key, hasBaseline, baseline
|
|
1674
|
+
for (const value of candidateValues(key, hasBaseline, baseline, deferred &&
|
|
1675
|
+
payload?.shapeFields?.includes(field) === true &&
|
|
1676
|
+
baseline === null)) {
|
|
1607
1677
|
coverageCheckpoint();
|
|
1608
1678
|
if (probeBudget.probes > MAX_PROBES)
|
|
1609
1679
|
return undefined;
|
|
@@ -1624,13 +1694,13 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1624
1694
|
},
|
|
1625
1695
|
},
|
|
1626
1696
|
};
|
|
1627
|
-
const found = search(next, nextDepth);
|
|
1697
|
+
const found = yield* search(next, nextDepth, deferred);
|
|
1628
1698
|
if (found !== undefined)
|
|
1629
1699
|
return found;
|
|
1630
1700
|
}
|
|
1631
1701
|
}
|
|
1632
1702
|
return undefined;
|
|
1633
|
-
}
|
|
1703
|
+
}
|
|
1634
1704
|
const shapes = payloads;
|
|
1635
1705
|
const slots = shapes.flatMap((payload, index) => (payload.shapeFields ?? []).map((field) => ({ index, field })));
|
|
1636
1706
|
if (slots.length > 4)
|
|
@@ -1651,7 +1721,34 @@ function probeGuardAssignment(guard, fixedEvent, payloads, extraValues, options
|
|
|
1651
1721
|
}
|
|
1652
1722
|
return { ...payload, base, shapeFields: fields };
|
|
1653
1723
|
});
|
|
1654
|
-
const
|
|
1724
|
+
const paired = payloads.some((payload) => (payload.shapeFields?.length ?? 0) > 0);
|
|
1725
|
+
const continuations = [
|
|
1726
|
+
search(initial, 0, false),
|
|
1727
|
+
...(paired ? [search(initial, 0, true)] : []),
|
|
1728
|
+
];
|
|
1729
|
+
const active = continuations.map(() => true);
|
|
1730
|
+
let found;
|
|
1731
|
+
try {
|
|
1732
|
+
while (active.some(Boolean) && found === undefined) {
|
|
1733
|
+
for (let index = 0; index < continuations.length; index++) {
|
|
1734
|
+
if (!active[index])
|
|
1735
|
+
continue;
|
|
1736
|
+
const step = continuations[index].next();
|
|
1737
|
+
if (step.done) {
|
|
1738
|
+
active[index] = false;
|
|
1739
|
+
if (step.value !== undefined) {
|
|
1740
|
+
found = step.value;
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
finally {
|
|
1748
|
+
// Neither continuation may retain a suspended read across presence masks.
|
|
1749
|
+
for (const continuation of continuations)
|
|
1750
|
+
continuation.return(undefined);
|
|
1751
|
+
}
|
|
1655
1752
|
if (found === undefined)
|
|
1656
1753
|
continue;
|
|
1657
1754
|
for (const payload of payloads) {
|
|
@@ -3027,7 +3124,7 @@ export function fsmCoverageTestTimeout(fsmModule, coverage) {
|
|
|
3027
3124
|
MAX_PARALLEL_COMBINATIONS *
|
|
3028
3125
|
PARALLEL_SETTLE_MS, 0);
|
|
3029
3126
|
const guardAllowance = guardProbeCalls * Math.ceil(MAX_PROBES / PROBES_PER_TIMEOUT_MILLISECOND);
|
|
3030
|
-
return Math.min(
|
|
3127
|
+
return Math.min(budget.maxDurationMs, Math.max(MIN_COVERAGE_TEST_TIMEOUT_MS, rootSettles +
|
|
3031
3128
|
entrySettles +
|
|
3032
3129
|
captainSettles +
|
|
3033
3130
|
pathSettles +
|
|
@@ -3077,8 +3174,7 @@ async function fsmCoverage(fsmModule, opts = {}, literalChecks, literalOnly = fa
|
|
|
3077
3174
|
coverage,
|
|
3078
3175
|
literalChecks,
|
|
3079
3176
|
signal: opts.signal,
|
|
3080
|
-
deadline: started +
|
|
3081
|
-
Math.min(opts.timeoutMs ?? Infinity, MAX_COVERAGE_TEST_TIMEOUT_MS),
|
|
3177
|
+
deadline: started + Math.min(opts.timeoutMs ?? Infinity, coverage.maxDurationMs),
|
|
3082
3178
|
lastYield: started,
|
|
3083
3179
|
actors: new Set(),
|
|
3084
3180
|
questionFindings: new Set(),
|