SWE Multi-Domain
Demo Pack
Ten fully simulated enterprise software companies — one per domain — each with a real injected defect, the on-call Slack thread around it, and an execution-verified fail→patch→pass cycle. This is the actual dataset shipped on our storefront: no marketing constructs, no cherry-picked screenshots.
What's in the pack
Every record carries the buggy source, the test that gates it, the gold patch, the fixed source, and the full incident thread — packaged with a canary and a documented verification pipeline.
fail-before / git apply / pass-after, executed at package time — every world is executed, not assumed.
Evaluation use only. Not licensed for model training or redistribution without agreement. · Canary: e52fc5be-d91b-4b52-b410-287271e9c420
The 10 worlds
Ten industries, ten distinct defect classes, zero repeated problems. Click a card to inspect it below.
processCartItem() in registry accesses cart[index] without checking if the index is within bounds. If cart items are removed (e.g., concurrent stock check removes out-of-stock items), the index becomes stale and access returns undefined, causing a crash or undefined behavior. Fixed by adding bounds and nullity checks.
3 fail → 3 pass · #inc-ecommerce
purchaseItem() multiplies unit price by a caller-supplied quantity without validating it. Submitting a negative quantity yields a negative cost, which passes the funds check and then increases the player's balance — an unlimited currency mint. Fixed by requiring a positive integer quantity.
3 fail → 3 pass · #inc-gaming
usageDelta() subtracts the previous register reading from the current one with no wraparound handling. When the meter passes its maximum and returns to zero the delta goes sharply negative, and the billing run either credits the customer or rejects the read. Fixed by detecting the wrap and adding the rollover span.
3 fail → 3 pass · #inc-energy
totalManifestWeight() parses each declared pallet weight with parseInt, discarding the fractional kilograms. Across a full trailer the manifest under-states the payload, so an axle-weight check that reads this total can clear a load that is actually over the legal limit. Fixed by parsing the decimal value.
3 fail → 3 pass · #inc-logistics
seatsAvailable() subtracts only confirmed bookings from the cabin total and ignores seats under a temporary payment hold. During checkout the same seat is offered to another customer, producing oversold flights that surface only at the gate. Fixed by subtracting held seats as well.
3 fail → 3 pass · #inc-travel
isOverTemp() compares a Celsius sensor reading against a limit configured in Fahrenheit without converting either value. Because the Fahrenheit number is numerically larger, the over-temperature alarm stays silent through the entire real danger band and only trips at roughly twice the intended threshold. Fixed by converting the reading before comparison.
3 fail → 3 pass · #inc-iot
gradeSubmission() compares the score with strict greater-than against the pass mark, so a student scoring exactly the published threshold is graded as a fail. Every cohort loses the boundary band, and the error is invisible in aggregate pass-rate reporting. Fixed by using an inclusive comparison.
3 fail → 3 pass · #inc-edtech
calculateTotal() uses Number multiplication (dispatch service), which overflows for values above Number.MAX_SAFE_INTEGER (9,007,199,254,740,991). When processing large USD amounts, the product silently loses precision. Fixed by using BigInt arithmetic.
3 fail → 3 pass · #inc-fintech
checkCertExpiry() in ledger uses >= instead of >, so a certificate whose validity window ends exactly at the current instant is still reported valid and the expiry passes silently. Fixed by requiring validTo strictly greater than now.
3 fail → 3 pass · #inc-devops
Dispatch position lookup falls back to an arbitrary cached fix from the shared telemetry map when the requested ambulance unit has no recent GPS report, returning another vehicle's coordinates to the wrong dispatch sphere and omitting any staleness evaluation against the maximum fix age window.
3 fail → 3 pass · #inc-healthcare
Inspect a world
Pick a domain: read the incident thread the way an agent would, then flip between the buggy and fixed source, the gold patch, and the gating tests.
processCartItem() in registry accesses cart[index] without checking if the index is within bounds. If cart items are removed (e.g., concurrent stock check removes out-of-stock items), the index becomes stale and access returns undefined, causing a crash or undefined behavior. Fixed by adding bounds and nullity checks.
Incident thread
The on-call thread the engineering agent must trace, from #inc-ecommerce.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: SysShield | Ticket: TICKET-5733 | Trace: INC-553 function processCartItem(userCart_89, index) { // BUG: Direct array access without bounds check // Items may have been removed concurrently or by other logic const item = userCart_89[index]; return { itemId: item.id, name: item.name, price: item.price, quantity: item.quantity, }; } module.exports = { processCartItem };
// Enterprise Component: SysShield | Ticket: TICKET-5733 | Trace: INC-553 function processCartItem(userCart_89, index) { // FIX: Bounds check before accessing array if (index < 0 || index >= userCart_89.length) { return { error: 'Item not found at index ' + index }; } const item = userCart_89[index]; if (!item) { return { error: 'Item is null or removed' }; } return { itemId: item.id, name: item.name, price: item.price, quantity: item.quantity, }; } module.exports = { processCartItem };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,8 +1,13 @@ // Enterprise Component: SysShield | Ticket: TICKET-5733 | Trace: INC-553 function processCartItem(userCart_89, index) { - // BUG: Direct array access without bounds check - // Items may have been removed concurrently or by other logic + // FIX: Bounds check before accessing array + if (index < 0 || index >= userCart_89.length) { + return { error: 'Item not found at index ' + index }; + } const item = userCart_89[index]; + if (!item) { + return { error: 'Item is null or removed' }; + } return { itemId: item.id, name: item.name,
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for SysShield (TICKET-5733) const assert = require('assert'); const { processCartItem } = require('../src/handler'); describe('CHECKOUT_OUT_OF_BOUNDS Fix Test', function() { it('should handle invalid index gracefully', function() { const userCart_89 = [{ id: 'ITEM-001', name: 'Widget', price: 9.99, quantity: 2 }]; const result = processCartItem(userCart_89, 5); assert.ok(result.error, 'Should return error for out-of-bounds index'); assert.ok(result.error.includes('not found')); }); it('should process valid userCart_89 dataPayload_8', function() { const userCart_89 = [ { id: 'ITEM-001', name: 'Widget', price: 9.99, quantity: 2 }, { id: 'ITEM-002', name: 'Gadget', price: 24.99, quantity: 1 }, ]; const result = processCartItem(userCart_89, 1); assert.strictEqual(result.itemId, 'ITEM-002'); assert.strictEqual(result.price, 24.99); }); it('should handle negative index', function() { const userCart_89 = [{ id: 'ITEM-001', name: 'Widget', price: 9.99, quantity: 2 }]; const result = processCartItem(userCart_89, -1); assert.ok(result.error, 'Should return error for negative index'); }); });
purchaseItem() multiplies unit price by a caller-supplied quantity without validating it. Submitting a negative quantity yields a negative cost, which passes the funds check and then increases the player's balance — an unlimited currency mint. Fixed by requiring a positive integer quantity.
Incident thread
The on-call thread the engineering agent must trace, from #inc-gaming.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: CloudCart | Ticket: TICKET-2935 | Trace: INC-874 function purchaseItem(account, itemPrice, quantity) { // BUG: quantity is never validated. A negative quantity makes the // charge negative, crediting the player instead of debiting them. const cost = itemPrice * quantity; if (account.balance < cost) { return { ok: false, reason: 'insufficient funds' }; } account.balance = account.balance - cost; return { ok: true, balance: account.balance }; } module.exports = { purchaseItem };
// Enterprise Component: CloudCart | Ticket: TICKET-2935 | Trace: INC-874 function purchaseItem(account, itemPrice, quantity) { // FIX: require a positive whole quantity before pricing anything. if (!Number.isInteger(quantity) || quantity < 1) { return { ok: false, reason: 'invalid quantity' }; } const cost = itemPrice * quantity; if (account.balance < cost) { return { ok: false, reason: 'insufficient funds' }; } account.balance = account.balance - cost; return { ok: true, balance: account.balance }; } module.exports = { purchaseItem };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,7 +1,9 @@ // Enterprise Component: CloudCart | Ticket: TICKET-2935 | Trace: INC-874 function purchaseItem(account, itemPrice, quantity) { - // BUG: quantity is never validated. A negative quantity makes the - // charge negative, crediting the player instead of debiting them. + // FIX: require a positive whole quantity before pricing anything. + if (!Number.isInteger(quantity) || quantity < 1) { + return { ok: false, reason: 'invalid quantity' }; + } const cost = itemPrice * quantity; if (account.balance < cost) { return { ok: false, reason: 'insufficient funds' };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for CloudCart (TICKET-2935) const assert = require('assert'); const { purchaseItem } = require('../src/handler'); describe('STORE_NEGATIVE_QUANTITY_CREDIT', function() { it('should reject a negative quantity instead of crediting the account', function() { const account = { balance: 1000 }; const result = purchaseItem(account, 120, -5); assert.strictEqual(result.ok, false); assert.strictEqual(account.balance, 1000, 'balance must be untouched by a rejected purchase'); }); it('should charge correctly for a valid purchase', function() { const account = { balance: 1000 }; const result = purchaseItem(account, 120, 2); assert.strictEqual(result.ok, true); assert.strictEqual(account.balance, 760); }); });
usageDelta() subtracts the previous register reading from the current one with no wraparound handling. When the meter passes its maximum and returns to zero the delta goes sharply negative, and the billing run either credits the customer or rejects the read. Fixed by detecting the wrap and adding the rollover span.
Incident thread
The on-call thread the engineering agent must trace, from #inc-energy.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: CurisTech | Ticket: TICKET-3887 | Trace: INC-453 function usageDelta(previousReading, currentReading, meterMax) { // BUG: a mechanical register wraps to zero at meterMax. Subtracting // directly yields a large negative delta for the billing period // that spans the rollover. return currentReading - previousReading; } module.exports = { usageDelta };
// Enterprise Component: CurisTech | Ticket: TICKET-3887 | Trace: INC-453 function usageDelta(previousReading, currentReading, meterMax) { // FIX: detect the wrap and account for the register rolling over. if (currentReading >= previousReading) { return currentReading - previousReading; } return (meterMax - previousReading) + currentReading + 1; } module.exports = { usageDelta };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,8 +1,9 @@ // Enterprise Component: CurisTech | Ticket: TICKET-3887 | Trace: INC-453 function usageDelta(previousReading, currentReading, meterMax) { - // BUG: a mechanical register wraps to zero at meterMax. Subtracting - // directly yields a large negative delta for the billing period - // that spans the rollover. - return currentReading - previousReading; + // FIX: detect the wrap and account for the register rolling over. + if (currentReading >= previousReading) { + return currentReading - previousReading; + } + return (meterMax - previousReading) + currentReading + 1; } module.exports = { usageDelta };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for CurisTech (TICKET-3887) const assert = require('assert'); const { usageDelta } = require('../src/handler'); describe('METER_ROLLOVER_NEGATIVE_USAGE', function() { const METER_MAX = 999999; it('should compute positive usage across a register rollover', function() { const d = usageDelta(999979, 30, METER_MAX); assert.strictEqual(d, 51); }); it('should never report negative usage', function() { const d = usageDelta(999979, 30, METER_MAX); assert.ok(d > 0, 'usage must be positive, got ' + d); }); it('should compute a normal in-period delta', function() { const d = usageDelta(100, 175, METER_MAX); assert.strictEqual(d, 75); }); });
totalManifestWeight() parses each declared pallet weight with parseInt, discarding the fractional kilograms. Across a full trailer the manifest under-states the payload, so an axle-weight check that reads this total can clear a load that is actually over the legal limit. Fixed by parsing the decimal value.
Incident thread
The on-call thread the engineering agent must trace, from #inc-logistics.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: DevPulse | Ticket: TICKET-8250 | Trace: INC-771 function totalManifestWeight(recordEntries_74) { // BUG: parseInt discards the fractional part of each declared // weight, so the manifest under-reports the true payload. return recordEntries_74.reduce(function (sum, item) { return sum + parseInt(item.weightKg, 10); }, 0); } module.exports = { totalManifestWeight };
// Enterprise Component: DevPulse | Ticket: TICKET-8250 | Trace: INC-771 function totalManifestWeight(recordEntries_74) { // FIX: parse the full decimal weight. return recordEntries_74.reduce(function (sum, item) { return sum + parseFloat(item.weightKg); }, 0); } module.exports = { totalManifestWeight };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,9 +1,8 @@ // Enterprise Component: DevPulse | Ticket: TICKET-8250 | Trace: INC-771 function totalManifestWeight(recordEntries_74) { - // BUG: parseInt discards the fractional part of each declared - // weight, so the manifest under-reports the true payload. + // FIX: parse the full decimal weight. return recordEntries_74.reduce(function (sum, item) { - return sum + parseInt(item.weightKg, 10); + return sum + parseFloat(item.weightKg); }, 0); } module.exports = { totalManifestWeight };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for DevPulse (TICKET-8250) const assert = require('assert'); const { totalManifestWeight } = require('../src/handler'); describe('MANIFEST_WEIGHT_TRUNCATION', function() { it('should sum declared weights without truncating decimals', function() { const total = totalManifestWeight([ { sku: 'PAL-1', weightKg: '7.3' }, { sku: 'PAL-2', weightKg: '9.2' } ]); assert.ok(Math.abs(total - 16.5) < 1e-9, 'expected 16.5 but got ' + total); }); it('should not report the truncated integer total', function() { const total = totalManifestWeight([ { sku: 'PAL-1', weightKg: '7.3' }, { sku: 'PAL-2', weightKg: '9.2' } ]); assert.notStrictEqual(total, 16); }); });
seatsAvailable() subtracts only confirmed bookings from the cabin total and ignores seats under a temporary payment hold. During checkout the same seat is offered to another customer, producing oversold flights that surface only at the gate. Fixed by subtracting held seats as well.
Incident thread
The on-call thread the engineering agent must trace, from #inc-travel.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: OmniCare | Ticket: TICKET-9382 | Trace: INC-995 function seatsAvailable(inventory) { // BUG: seats on temporary hold are still counted as available, so // the same seat can be sold to a second customer while the first // is completing payment. return inventory.total - inventory.booked; } module.exports = { seatsAvailable };
// Enterprise Component: OmniCare | Ticket: TICKET-9382 | Trace: INC-995 function seatsAvailable(inventory) { // FIX: a held seat is not available until the hold expires. const held = inventory.held || 0; return inventory.total - inventory.booked - held; } module.exports = { seatsAvailable };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,8 +1,7 @@ // Enterprise Component: OmniCare | Ticket: TICKET-9382 | Trace: INC-995 function seatsAvailable(inventory) { - // BUG: seats on temporary hold are still counted as available, so - // the same seat can be sold to a second customer while the first - // is completing payment. - return inventory.total - inventory.booked; + // FIX: a held seat is not available until the hold expires. + const held = inventory.held || 0; + return inventory.total - inventory.booked - held; } module.exports = { seatsAvailable };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for OmniCare (TICKET-9382) const assert = require('assert'); const { seatsAvailable } = require('../src/handler'); describe('HELD_SEAT_AVAILABILITY_OVERCOUNT', function() { it('should exclude held seats from availability', function() { const n = seatsAvailable({ total: 180, booked: 60, held: 15 }); assert.strictEqual(n, 105); }); it('should equal total minus booked when nothing is held', function() { const n = seatsAvailable({ total: 180, booked: 60, held: 0 }); assert.strictEqual(n, 120); }); });
isOverTemp() compares a Celsius sensor reading against a limit configured in Fahrenheit without converting either value. Because the Fahrenheit number is numerically larger, the over-temperature alarm stays silent through the entire real danger band and only trips at roughly twice the intended threshold. Fixed by converting the reading before comparison.
Incident thread
The on-call thread the engineering agent must trace, from #inc-iot.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: ApexHealth | Ticket: TICKET-8101 | Trace: INC-619 function isOverTemp(readingCelsius, limitFahrenheit) { // BUG: the sensor reports Celsius but the configured alarm limit is // Fahrenheit. Comparing them directly means the alarm only fires // far past the real threshold. return readingCelsius > limitFahrenheit; } module.exports = { isOverTemp };
// Enterprise Component: ApexHealth | Ticket: TICKET-8101 | Trace: INC-619 function isOverTemp(readingCelsius, limitFahrenheit) { // FIX: convert the reading to the limit's unit before comparing. const readingFahrenheit = (readingCelsius * 9 / 5) + 32; return readingFahrenheit > limitFahrenheit; } module.exports = { isOverTemp };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,8 +1,7 @@ // Enterprise Component: ApexHealth | Ticket: TICKET-8101 | Trace: INC-619 function isOverTemp(readingCelsius, limitFahrenheit) { - // BUG: the sensor reports Celsius but the configured alarm limit is - // Fahrenheit. Comparing them directly means the alarm only fires - // far past the real threshold. - return readingCelsius > limitFahrenheit; + // FIX: convert the reading to the limit's unit before comparing. + const readingFahrenheit = (readingCelsius * 9 / 5) + 32; + return readingFahrenheit > limitFahrenheit; } module.exports = { isOverTemp };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for ApexHealth (TICKET-8101) const assert = require('assert'); const { isOverTemp } = require('../src/handler'); describe('THERMAL_UNIT_MISMATCH', function() { const LIMIT_F = 122; it('should raise the alarm for a Celsius reading above the limit', function() { assert.strictEqual(isOverTemp(55, LIMIT_F), true); }); it('should stay silent for a reading well below the limit', function() { assert.strictEqual(isOverTemp(30, LIMIT_F), false); }); });
gradeSubmission() compares the score with strict greater-than against the pass mark, so a student scoring exactly the published threshold is graded as a fail. Every cohort loses the boundary band, and the error is invisible in aggregate pass-rate reporting. Fixed by using an inclusive comparison.
Incident thread
The on-call thread the engineering agent must trace, from #inc-edtech.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: SysShield | Ticket: TICKET-5109 | Trace: INC-137 function gradeSubmission(score, passMark) { // BUG: strict greater-than excludes the boundary, so a student who // scores exactly the pass mark is recorded as a fail. if (score > passMark) { return { passed: true, band: 'pass' }; } return { passed: false, band: 'fail' }; } module.exports = { gradeSubmission };
// Enterprise Component: SysShield | Ticket: TICKET-5109 | Trace: INC-137 function gradeSubmission(score, passMark) { // FIX: the pass mark itself is a passing score. if (score >= passMark) { return { passed: true, band: 'pass' }; } return { passed: false, band: 'fail' }; } module.exports = { gradeSubmission };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,8 +1,7 @@ // Enterprise Component: SysShield | Ticket: TICKET-5109 | Trace: INC-137 function gradeSubmission(score, passMark) { - // BUG: strict greater-than excludes the boundary, so a student who - // scores exactly the pass mark is recorded as a fail. - if (score > passMark) { + // FIX: the pass mark itself is a passing score. + if (score >= passMark) { return { passed: true, band: 'pass' }; } return { passed: false, band: 'fail' };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for SysShield (TICKET-5109) const assert = require('assert'); const { gradeSubmission } = require('../src/handler'); describe('PASS_MARK_BOUNDARY_EXCLUSION', function() { const PASS_MARK = 50; it('should pass a submission scoring exactly the pass mark', function() { const r = gradeSubmission(PASS_MARK, PASS_MARK); assert.strictEqual(r.passed, true); }); it('should fail a submission one point below the pass mark', function() { const r = gradeSubmission(PASS_MARK - 1, PASS_MARK); assert.strictEqual(r.passed, false); }); it('should pass a submission above the pass mark', function() { const r = gradeSubmission(PASS_MARK + 10, PASS_MARK); assert.strictEqual(r.passed, true); }); });
calculateTotal() uses Number multiplication (dispatch service), which overflows for values above Number.MAX_SAFE_INTEGER (9,007,199,254,740,991). When processing large USD amounts, the product silently loses precision. Fixed by using BigInt arithmetic.
Incident thread
The on-call thread the engineering agent must trace, from #inc-fintech.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: PrimeStore | Ticket: TICKET-5155 | Trace: INC-131 function calculateTotal(unitPrice, quantity) { // BUG: Number multiplication can overflow for large money values // Example: 9999999999 * 9999999999 overflows Number.MAX_SAFE_INTEGER return unitPrice * quantity; } module.exports = { calculateTotal };
// Enterprise Component: PrimeStore | Ticket: TICKET-5155 | Trace: INC-131 function calculateTotal(unitPrice, quantity) { // FIX: Use BigInt for large money calculations to prevent overflow const total = BigInt(unitPrice) * BigInt(quantity); return total; } module.exports = { calculateTotal };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,7 +1,7 @@ // Enterprise Component: PrimeStore | Ticket: TICKET-5155 | Trace: INC-131 function calculateTotal(unitPrice, quantity) { - // BUG: Number multiplication can overflow for large money values - // Example: 9999999999 * 9999999999 overflows Number.MAX_SAFE_INTEGER - return unitPrice * quantity; + // FIX: Use BigInt for large money calculations to prevent overflow + const total = BigInt(unitPrice) * BigInt(quantity); + return total; } module.exports = { calculateTotal };
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for PrimeStore (TICKET-5155) const assert = require('assert'); const { calculateTotal } = require('../src/handler'); describe('PAYMENT_AMOUNT_OVERFLOW Fix Test', function() { it('should handle large payment amounts without overflow', function() { const result = calculateTotal(9999999999, 9999999999); // Number.MAX_SAFE_INTEGER = 9007199254740991 // BigInt result = 99999999980000000001n — overflows with Number const expected = BigInt(9999999999) * BigInt(9999999999); assert.strictEqual(result, expected); }); it('should handle normal amounts correctly', function() { const result = calculateTotal(100, 5); assert.strictEqual(result, 500n); }); });
checkCertExpiry() in ledger uses >= instead of >, so a certificate whose validity window ends exactly at the current instant is still reported valid and the expiry passes silently. Fixed by requiring validTo strictly greater than now.
Incident thread
The on-call thread the engineering agent must trace, from #inc-devops.
Source · src/handler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// Enterprise Component: InfraVault | Ticket: TICKET-7677 | Trace: INC-784
function checkCertExpiry(sslCert_84, now) {
const t = (typeof now === 'number') ? now : Date.now();
if (sslCert_84.validTo >= t)
return { valid: true, expiresIn: sslCert_84.validTo - t };
return { valid: false, reason: 'Certificate expired' };
}
module.exports = { checkCertExpiry };
// Enterprise Component: InfraVault | Ticket: TICKET-7677 | Trace: INC-784
function checkCertExpiry(sslCert_84, now) {
const t = (typeof now === 'number') ? now : Date.now();
if (sslCert_84.validTo > t)
return { valid: true, expiresIn: sslCert_84.validTo - t };
return { valid: false, reason: 'Certificate expired' };
}
module.exports = { checkCertExpiry };
diff --git a/src/handler.js b/src/handler.js --- a/src/handler.js +++ b/src/handler.js @@ -1,7 +1,7 @@ // Enterprise Component: InfraVault | Ticket: TICKET-7677 | Trace: INC-784 function checkCertExpiry(sslCert_84, now) { const t = (typeof now === 'number') ? now : Date.now(); - if (sslCert_84.validTo >= t) + if (sslCert_84.validTo > t) return { valid: true, expiresIn: sslCert_84.validTo - t }; return { valid: false, reason: 'Certificate expired' }; }
// Test shim if (typeof describe === 'undefined') { global.describe = function (name, fn) { fn(); }; global.it = function (name, fn) { fn(); }; } // Automated Test Suite for InfraVault (TICKET-7677) const assert = require('assert'); const { checkCertExpiry } = require('../src/handler'); describe('CERT_EXPIRY', function() { // A fixed clock is injected so the boundary case is deterministic; // reading Date.now() twice made this test race against itself. const NOW = 1750000000000; it('should reject sslCert_84 whose validity ends exactly now', function() { const r = checkCertExpiry({ validTo: NOW }, NOW); assert.strictEqual(r.valid, false); }); it('should accept valid sslCert_84', function() { const r = checkCertExpiry({ validTo: NOW + 86400000 }, NOW); assert.strictEqual(r.valid, true); }); });
Dispatch position lookup falls back to an arbitrary cached fix from the shared telemetry map when the requested ambulance unit has no recent GPS report, returning another vehicle's coordinates to the wrong dispatch sphere and omitting any staleness evaluation against the maximum fix age window.
Incident thread
The on-call thread the engineering agent must trace, from #inc-healthcare.
Source · src/serviceHandler.js
The same file before and after the gold patch. Bug is injected; tests gate both states.
// svc-ambulance-gps-stale-data — clinical service module // build world_sample const _positionCache = {}; function reportPosition(unitId, lat, lon, timestampMs) { _positionCache[unitId] = { lat, lon, timestampMs }; return true; } function getDispatchPosition(unitId, nowMs) { const hit = _positionCache[unitId]; if (hit) return { unitId, lat: hit.lat, lon: hit.lon, stale: false }; const anyKey = Object.keys(_positionCache)[0]; if (anyKey) { const other = _positionCache[anyKey]; return { unitId, lat: other.lat, lon: other.lon, stale: false }; } return null; } module.exports = { reportPosition, getDispatchPosition, MAX_FIX_AGE_MS: 90000 };
// svc-ambulance-gps-stale-data — AMBULANCE_GPS_STALE_DATA (CWE-668: Exposure of Resource to Wrong Sphere in Dispatch Tracking) // world=world_sample const _positionCache = {}; const MAX_FIX_AGE_MS = 90000; function reportPosition(unitId, lat, lon, timestampMs) { _positionCache[unitId] = { lat, lon, timestampMs }; return true; } function getDispatchPosition(unitId, nowMs) { const hit = _positionCache[unitId]; if (!hit) return null; if (nowMs - hit.timestampMs > MAX_FIX_AGE_MS) { return { unitId, lat: null, lon: null, stale: true }; } return { unitId, lat: hit.lat, lon: hit.lon, stale: false }; } module.exports = { reportPosition, getDispatchPosition, MAX_FIX_AGE_MS };
diff --git a/src/serviceHandler.js b/src/serviceHandler.js index 9a6f1c8..e89d6b9 100644 --- a/src/serviceHandler.js +++ b/src/serviceHandler.js @@ -1,7 +1,8 @@ -// svc-ambulance-gps-stale-data — clinical service module -// build world_sample +// svc-ambulance-gps-stale-data — AMBULANCE_GPS_STALE_DATA (CWE-668: Exposure of Resource to Wrong Sphere in Dispatch Tracking) +// world=world_sample const _positionCache = {}; +const MAX_FIX_AGE_MS = 90000; function reportPosition(unitId, lat, lon, timestampMs) { _positionCache[unitId] = { lat, lon, timestampMs }; @@ -10,13 +11,11 @@ function reportPosition(unitId, lat, lon, timestampMs) { function getDispatchPosition(unitId, nowMs) { const hit = _positionCache[unitId]; - if (hit) return { unitId, lat: hit.lat, lon: hit.lon, stale: false }; - const anyKey = Object.keys(_positionCache)[0]; - if (anyKey) { - const other = _positionCache[anyKey]; - return { unitId, lat: other.lat, lon: other.lon, stale: false }; + if (!hit) return null; + if (nowMs - hit.timestampMs > MAX_FIX_AGE_MS) { + return { unitId, lat: null, lon: null, stale: true }; } - return null; + return { unitId, lat: hit.lat, lon: hit.lon, stale: false }; } -module.exports = { reportPosition, getDispatchPosition, MAX_FIX_AGE_MS: 90000 }; \ No newline at end of file +module.exports = { reportPosition, getDispatchPosition, MAX_FIX_AGE_MS };
const assert = require('assert');
const { reportPosition, getDispatchPosition } = require('../src/serviceHandler');
reportPosition('MEDIC-345', 40.6782, -73.9442, 1000);
// A unit with no fix of its own must never receive another unit's coordinates.
const foreign = getDispatchPosition('MEDIC-978', 1200);
assert.strictEqual(foreign, null,
'unit with no GPS fix received another ambulance position (CWE-668)');
// A fix older than the max age must be reported stale, not as live position.
reportPosition('MEDIC-978', 40.7002, -73.9200, 1000);
const stale = getDispatchPosition('MEDIC-978', 1000 + 90000 + 1);
assert.strictEqual(stale.stale, true, 'expired GPS fix reported as live');
assert.strictEqual(stale.lat, null, 'stale fix still exposed coordinates');
const fresh = getDispatchPosition('MEDIC-345', 1100);
assert.strictEqual(fresh.stale, false);
assert.strictEqual(fresh.lat, 40.6782);
console.log('ok ambulance dispatch position scoping');
const _mod = require('../src/serviceHandler');
assert(typeof _mod === 'object' && Object.keys(_mod).length > 0,
'service module exported nothing');
Splits
Pre-baked train/val/test splits so you can benchmark against the same world alignment we use.
| Split | Worlds |
|---|---|
| test | 3 |
| train | 5 |
| val | 2 |
Start with the real thing
Download the pack directly, or grab the full SWE-Enterprise corpus with 24,316 worlds for training-scale work.