agenttwin 0.3.32 → 0.3.34
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/api.js +14217 -2453
- package/dist/dashboard/assets/next/static/chunks/{1937-6c86fddc443de922.js → 1937-2369d8ef2eae7700.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/_not-found/{page-5d1ba67144da5868.js → page-b60a5aad66f3bf1d.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/about/page-a30c6925cc9ac983.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/account/password/page-0478a7f18cc5e31b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/auth/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-mockoon/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-pact/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-testcontainers/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-wiremock/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/choose-first-agent-workflow-test/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/clean-baseline-before-fault-injection/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/idempotency-keys-and-safe-retries/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/keep-real-service-tests-with-digital-twins/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/keploy-alternatives-for-database-and-payment-workflows/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/layout-6c159db381b82832.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/read-workflow-test-receipts/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/reset-test-environment-between-runs/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/simulate-timeouts-and-duplicate-events/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/test-boundaries-for-ai-agents/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/timeout-retry-double-charge/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/we-ran-50-real-incidents-through-agenttwin/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/why-ai-agents-delete-production-databases/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/workflow-testing-evaluation-checklist/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/write-better-workflow-assertions/page-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/compare/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/contact/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-0050f308b9f77c24.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/page-6245aa3ad5d7f527.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/demo/{page-ef75632088a6ea0b.js → page-ac6e235c635cb130.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/developers/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-5afd0649dd30ef88.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dpa/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/enterprise/{page-91c6176f28dfdccd.js → page-11514cc52285b7f3.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/guides/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/{layout-be64d3e50db4b7a9.js → layout-8aa153f632f0aa20.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/login/page-99ebb4d265222728.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/not-found-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-9e59af0296c9366b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/{page-ede77810f4904ea5.js → page-76277dc68b6a22bd.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/{blog/layout-b095a34d742bd1fd.js → pricing/page-c7015af858f4db8e.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/privacy/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/security/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/signup/page-99ebb4d265222728.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/sitemap.xml/route-46b9ffc514b56c84.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/status/{page-569ae36bd08d867c.js → page-fd41c4e7838d9949.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/terms/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{layout-b92ad482b0164f93.js → layout-a79d128eb3b0b7d2.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-a9fa05c9ae5c24dc.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/layout-2e97381ae7a59ba0.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-57afbac97afd31fa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/{page-79cd80f87d39230d.js → page-7c08d2c43f0be9d5.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-35998431fb40a9c9.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-57afbac97afd31fa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-91ad6c5e4226778f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/{main-app-b4faf61f2e1c2b6d.js → main-app-4051d8ba998bea15.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{webpack-53525dd96c1c1e70.js → webpack-57e0c1e343bdc899.js} +1 -1
- package/dist/dashboard/assets/next/static/p_5KE1JZcErklSND_EYv3/_buildManifest.js +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/engine.js +1358 -565
- package/dist/gateway.js +14235 -2467
- package/dist/twins/catalog.json +113 -113
- package/dist/twins/packs/stripe/index.mjs +8 -8
- package/dist/worker.js +97 -20
- package/dist/world-host.js +140 -26
- package/package.json +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/about/page-b09a2d8452522c20.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/account/password/page-b9ca284314cace59.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/auth/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-mockoon/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-pact/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-testcontainers/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/agenttwin-vs-wiremock/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/choose-first-agent-workflow-test/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/clean-baseline-before-fault-injection/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/idempotency-keys-and-safe-retries/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/keep-real-service-tests-with-digital-twins/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/keploy-alternatives-for-database-and-payment-workflows/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/read-workflow-test-receipts/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/reset-test-environment-between-runs/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/simulate-timeouts-and-duplicate-events/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/test-boundaries-for-ai-agents/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/workflow-testing-evaluation-checklist/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/write-better-workflow-assertions/page-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/compare/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/contact/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-820e83f47c1bfe08.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/page-8b436163bc85e182.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/developers/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-c25a8cab5ab065c4.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dpa/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/guides/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/login/page-7ee25051f2743d68.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/not-found-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-26b963fb1dc02cc7.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/pricing/page-535834810dc4bee1.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/privacy/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/security/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/signup/page-7ee25051f2743d68.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/sitemap.xml/route-11a5fdc2662ff51d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/terms/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-b1341267b2478360.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/layout-edb84faba63372b4.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-bfbe86a28adc6d30.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-1391f1ae01a91dc0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-bfbe86a28adc6d30.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-94d508052ae30dcb.js +0 -1
- package/dist/dashboard/assets/next/static/dQPcd2gl7ABZiL9lr9ruM/_buildManifest.js +0 -1
- /package/dist/dashboard/assets/next/static/{dQPcd2gl7ABZiL9lr9ruM → p_5KE1JZcErklSND_EYv3}/_ssgManifest.js +0 -0
package/dist/worker.js
CHANGED
|
@@ -416,7 +416,9 @@ function esbuildBinary(real){const match=real.match(/^(.*[\/\\]node_modules[\/\\
|
|
|
416
416
|
// the same name inside a project or earlier on PATH is still reported.
|
|
417
417
|
const SYSTEM_INFO_BINARIES=new Set(['/usr/bin/uname','/bin/uname','/usr/bin/sw_vers','/usr/bin/arch','/usr/bin/nproc','/usr/bin/getconf']);
|
|
418
418
|
function systemInfoBinary(real){return process.platform!=='win32'&&SYSTEM_INFO_BINARIES.has(real);}
|
|
419
|
-
|
|
419
|
+
// pnpm's node_modules/.bin entries are sh scripts that exec node on the package's JS: the child is Node and loads the hook.
|
|
420
|
+
function pnpmNodeShim(real,text){if(!/[\\/]node_modules[\\/]\.bin[\\/]/.test(real)||!/^#!\/bin\/sh/.test(text))return false;const execs=[...text.matchAll(/\bexec\s+(\S+)/g)].map(m=>m[1]);return execs.length>0&&execs.every(e=>/^(?:node|"\$basedir\/node)(?:\.exe)?"?$/.test(e));}
|
|
421
|
+
function trustedExecutable(file,options){const real=nodeFs.realpathSync(file);const key=real+'\0'+String(envPath((options&&options.env)||process.env)||'');if(executableTrust.has(key))return executableTrust.get(key);let trusted=real===nodeReal||esbuildBinary(real)||systemInfoBinary(real);if(!trusted&&isRunnable(real)){const fd=nodeFs.openSync(real,'r');try{const head=Buffer.alloc(8192);const read=nodeFs.readSync(fd,head,0,8192,0);const text=head.subarray(0,read).toString('latin1');trusted=nodeShebang(text.slice(0,256),options)||pnpmNodeShim(real,text);}finally{nodeFs.closeSync(fd);}}if(executableTrust.size<1000)executableTrust.set(key,trusted);return trusted;}
|
|
420
422
|
const reportedSubprocesses=new Set();
|
|
421
423
|
function hookedEnv(options){const env={...((options&&options.env)||process.env)};const current=env.NODE_OPTIONS||'';if(!current.includes(__filename))env.NODE_OPTIONS=(current+' '+hookOption).trim();env.AGENTTWIN_HOOK_CHILD='1';return {...(options||{}),env};}
|
|
422
424
|
// Never throws: an unclassifiable command is reported, and the application's spawn proceeds unchanged.
|
|
@@ -448,7 +450,9 @@ if(originalFetch)globalThis.fetch=async function(input,init){
|
|
|
448
450
|
const target=route?route.endpoint+url.pathname+url.search:url.href;
|
|
449
451
|
// Forward the body as bytes: copying a keepalive Request whose body is a stream throws in Node's fetch.
|
|
450
452
|
const body=request.method==='GET'||request.method==='HEAD'?undefined:await request.arrayBuffer();
|
|
451
|
-
|
|
453
|
+
const signal=init?.signal??(input instanceof Request?input.signal:undefined),sent=originalFetch(target,{method:request.method,headers,body,signal:request.signal,redirect:'error'});
|
|
454
|
+
if(!signal)return sent;if(signal.aborted)throw signal.reason;
|
|
455
|
+
return new Promise((resolve,reject)=>{const stop=()=>reject(signal.reason);signal.addEventListener('abort',stop,{once:true});sent.then(v=>{signal.removeEventListener('abort',stop);resolve(v);},e=>{signal.removeEventListener('abort',stop);reject(e);});});
|
|
452
456
|
};
|
|
453
457
|
const plainHttp={request:http.request,get:http.get};
|
|
454
458
|
const loopback=host=>['127.0.0.1','localhost','::1','[::1]'].includes(host);
|
|
@@ -5025,6 +5029,7 @@ function parseWorld(value) {
|
|
|
5025
5029
|
if (v.applicationClock !== void 0 && !validApplicationClock(v.applicationClock)) invalid("applicationClock requires only now as a canonical UTC timestamp with milliseconds");
|
|
5026
5030
|
if (!Array.isArray(v.services) || !v.services.length || v.services.length > 10) invalid("services must contain 1\u201310 HTTP services");
|
|
5027
5031
|
const services = /* @__PURE__ */ new Map();
|
|
5032
|
+
const requestPathFaults = /* @__PURE__ */ new Set();
|
|
5028
5033
|
for (const service of v.services) {
|
|
5029
5034
|
if (!object2(service) || typeof service.name !== "string" || !namePattern.test(service.name) || services.has(service.name)) invalid("service names must be unique lowercase identifiers");
|
|
5030
5035
|
const item = service;
|
|
@@ -5043,6 +5048,7 @@ function parseWorld(value) {
|
|
|
5043
5048
|
if (item.account !== void 0 && (!isPackAdapter(item.adapter) || !object2(item.account) || Object.keys(item.account).length > 10 || !Object.entries(item.account).every(([k, val]) => /^_?[a-z][a-z0-9_]{0,40}$/.test(k) && ["string", "number", "boolean"].includes(typeof val) && String(val).length <= 200))) invalid("account is for twin packs only: up to 10 simple fields with string, number or boolean values");
|
|
5044
5049
|
if (item.doorRecords !== void 0 && (!isPackAdapter(item.adapter) || !Array.isArray(item.doorRecords) || item.doorRecords.length > 5 || !item.doorRecords.every((r) => object2(r) && typeof r.type === "string" && /^[a-z][a-z0-9_]{0,40}$/.test(r.type) && typeof r.id === "string" && /^[A-Za-z0-9_.:-]{1,80}$/.test(r.id) && object2(r.fields) && JSON.stringify(r.fields).length <= 2e4))) invalid("doorRecords is for twin packs only: up to 5 records with a type, an id and their fields");
|
|
5045
5050
|
services.set(item.name, /* @__PURE__ */ new Set([...paths, ...optional]));
|
|
5051
|
+
if (typeof item.adapter === "string" && ADAPTER_COLLECTIONS[item.adapter] && !["stripe", "slack", "json-collection"].includes(item.adapter)) requestPathFaults.add(item.name);
|
|
5046
5052
|
}
|
|
5047
5053
|
const known2 = (entry) => typeof entry.service === "string" && typeof entry.path === "string" && services.get(entry.service)?.has(entry.path);
|
|
5048
5054
|
if (!Array.isArray(v.assertions) || !v.assertions.length || v.assertions.length > 100) invalid("at least one final-state assertion is required (maximum 100)");
|
|
@@ -5088,7 +5094,7 @@ function parseWorld(value) {
|
|
|
5088
5094
|
}
|
|
5089
5095
|
}
|
|
5090
5096
|
if (v.fault !== void 0) {
|
|
5091
|
-
if (!object2(v.fault) || !known2(v.fault) || !FAULT_TYPES.includes(v.fault.type)) invalid("fault requires an existing service/path and a supported type: timeout-after-write, blackhole, server-error, duplicate-write or slow-response");
|
|
5097
|
+
if (!object2(v.fault) || !(known2(v.fault) || requestPathFaults.has(String(v.fault.service)) && typeof v.fault.path === "string" && /^\/[a-zA-Z0-9_.:/-]+$/.test(v.fault.path) && !v.fault.path.includes("//")) || !FAULT_TYPES.includes(v.fault.type)) invalid("fault requires an existing service/path and a supported type: timeout-after-write, blackhole, server-error, duplicate-write or slow-response");
|
|
5092
5098
|
const f = v.fault;
|
|
5093
5099
|
const allowed = ["service", "path", "type"];
|
|
5094
5100
|
const count = f.count, windowMs = f.windowMs;
|
|
@@ -5458,6 +5464,7 @@ function aliasRequest(pack, host, url) {
|
|
|
5458
5464
|
// src/runtime/http-world.ts
|
|
5459
5465
|
import { tmpdir as tmpdir4 } from "os";
|
|
5460
5466
|
import { join as join7 } from "path";
|
|
5467
|
+
var KEYED_PACKS = /* @__PURE__ */ new Set(["resend"]);
|
|
5461
5468
|
var slackDirectMessageId = (user) => `D${createHash6("sha256").update(user).digest("hex").slice(0, 16).toUpperCase()}`;
|
|
5462
5469
|
var idempotencyKeyDigest = (key2) => typeof key2 === "string" && key2 ? `sha256:${createHash6("sha256").update(key2).digest("hex").slice(0, 16)}` : void 0;
|
|
5463
5470
|
var HttpWorld = class {
|
|
@@ -5856,7 +5863,7 @@ var HttpWorld = class {
|
|
|
5856
5863
|
return;
|
|
5857
5864
|
}
|
|
5858
5865
|
}
|
|
5859
|
-
if (!this.fired && result.operation === "write" && fault?.type === "timeout-after-write" && fault.service === service.name && fault.path === result.collection) {
|
|
5866
|
+
if (!this.fired && result.operation === "write" && fault?.type === "timeout-after-write" && fault.service === service.name && (fault.path === result.collection || matchesFault(normalPath(req.url ?? "/", req.method)))) {
|
|
5860
5867
|
this.fired = true;
|
|
5861
5868
|
this.faultActions++;
|
|
5862
5869
|
this.record(service.name, "fault", result.collection, `write committed; response delayed ${fault.delayMs}ms`);
|
|
@@ -6018,6 +6025,8 @@ var HttpWorld = class {
|
|
|
6018
6025
|
rawServers = [];
|
|
6019
6026
|
/** Each pack service's plain-TCP port for clients that open their own TLS sockets (see startPack). */
|
|
6020
6027
|
packTcp = /* @__PURE__ */ Object.create(null);
|
|
6028
|
+
/** Saved responses by service, path and Idempotency-Key, for packs whose vendor replays keyed requests. */
|
|
6029
|
+
packReplays = /* @__PURE__ */ new Map();
|
|
6021
6030
|
/**
|
|
6022
6031
|
* A twin pack served behind this world: the run token is checked and swapped for the credential the pack issued,
|
|
6023
6032
|
* seeded fault schedules apply around the pack's own handler, and every action the pack logs becomes evidence — writes
|
|
@@ -6125,7 +6134,7 @@ var HttpWorld = class {
|
|
|
6125
6134
|
const row = { id, ...a.fields ?? {} };
|
|
6126
6135
|
if (removed) {
|
|
6127
6136
|
if (at >= 0) rows2.splice(at, 1);
|
|
6128
|
-
} else if (at >= 0) rows2[at] = row;
|
|
6137
|
+
} else if (at >= 0) rows2[at] = { ...rows2[at], ...row };
|
|
6129
6138
|
else rows2.push(row);
|
|
6130
6139
|
if (!evidence) continue;
|
|
6131
6140
|
const byApp = a.actor?.kind === "agent" && !byWorld;
|
|
@@ -6272,6 +6281,13 @@ var HttpWorld = class {
|
|
|
6272
6281
|
return { status: r.status, headers: r.headers, bytes: model.restore(Buffer.from(await r.arrayBuffer())), actions: log.drain() };
|
|
6273
6282
|
};
|
|
6274
6283
|
if (workspace && method !== "GET") this.causing[service.name] = 1;
|
|
6284
|
+
const replayKey = !workspace && method === "POST" && typeof requestKey === "string" && requestKey && KEYED_PACKS.has(name) ? `${service.name}:${path}:${requestKey}` : void 0;
|
|
6285
|
+
const replay = replayKey ? this.packReplays.get(replayKey) : void 0;
|
|
6286
|
+
if (replay) {
|
|
6287
|
+
this.record(service.name, "twin", path, `replayed the first response for Idempotency-Key ${requestKey}; nothing written`);
|
|
6288
|
+
respond(replay.status, replay.out, replay.bytes);
|
|
6289
|
+
return;
|
|
6290
|
+
}
|
|
6275
6291
|
const first = await serialized(call).finally(() => {
|
|
6276
6292
|
if (workspace) this.causing[service.name] = 0;
|
|
6277
6293
|
});
|
|
@@ -6317,13 +6333,14 @@ var HttpWorld = class {
|
|
|
6317
6333
|
first.headers.forEach((v, k) => {
|
|
6318
6334
|
if (!/^(content-length|transfer-encoding|connection)$/i.test(k)) out[k] = v;
|
|
6319
6335
|
});
|
|
6320
|
-
if (
|
|
6336
|
+
if (replayKey && first.status < 500) this.packReplays.set(replayKey, { status: first.status, out, bytes: first.bytes });
|
|
6337
|
+
if (target && !this.fired && fault?.type === "timeout-after-write" && fault.service === service.name && (matchesFault(target) || matchesFault(path))) {
|
|
6321
6338
|
this.fired = true;
|
|
6322
6339
|
this.faultActions++;
|
|
6323
6340
|
this.record(service.name, "fault", target, `write committed; response delayed ${fault.delayMs}ms`);
|
|
6324
6341
|
this.keyed(requestKey);
|
|
6325
6342
|
later(fault.delayMs, () => send(first.status, out, first.bytes));
|
|
6326
|
-
} else if (fault?.type === "slow-response" && faultOrdinalsFor && matchesFault(target ?? path) && faultOrdinalsFor.includes(this.candidateIndex(faultKey))) {
|
|
6343
|
+
} else if (fault?.type === "slow-response" && faultOrdinalsFor && (matchesFault(target ?? path) || matchesFault(path)) && faultOrdinalsFor.includes(this.candidateIndex(faultKey))) {
|
|
6327
6344
|
this.faultActions++;
|
|
6328
6345
|
this.record(service.name, "fault", target ?? path, `slow-response: ${target ? "write" : "request"} applied; response delayed ${fault.delayMs}ms`);
|
|
6329
6346
|
this.keyed(requestKey);
|
|
@@ -7267,7 +7284,8 @@ function genericChecks(calls, opts = {}) {
|
|
|
7267
7284
|
impact: impactOf(group, made - 1, "data-integrity", `the same ${first.resourcePath.split("/").filter((s) => s !== "{id}").pop() ?? "record"} exists ${times(made)} downstream`),
|
|
7268
7285
|
...group[group.length - 1].source ? { source: group[group.length - 1].source } : {},
|
|
7269
7286
|
writeSites: sites(group),
|
|
7270
|
-
fix: announce ? "check-before-resend" : "idempotency-key"
|
|
7287
|
+
fix: announce ? "check-before-resend" : "idempotency-key",
|
|
7288
|
+
...group.length === 1 && first.duplicated && !first.idempotencyKey && !opts.duplicateDelivery ? { advisory: true } : {}
|
|
7271
7289
|
});
|
|
7272
7290
|
continue;
|
|
7273
7291
|
}
|
|
@@ -7300,9 +7318,9 @@ function genericChecks(calls, opts = {}) {
|
|
|
7300
7318
|
fix: "respect-retry-after"
|
|
7301
7319
|
});
|
|
7302
7320
|
}
|
|
7303
|
-
const unrecoveredBefore = (seq) => writes.filter((w) => w.sequence < seq && !announcementSeqs.has(w.sequence) && FAILED.includes(w.outcome) && w.outcome !== "lost-response" && !(w.outcome === "timeout" && w.committed) && !writes.some((r) => r.sequence > w.sequence && r.sequence < seq && sameRequest(w, r) && succeeded(r)));
|
|
7321
|
+
const unrecoveredBefore = (seq, via) => writes.filter((w) => w.sequence < seq && !(via && sameRequest(w, via) && succeeded(via)) && !announcementSeqs.has(w.sequence) && FAILED.includes(w.outcome) && w.outcome !== "lost-response" && !(w.outcome === "timeout" && w.committed) && !writes.some((r) => r.sequence > w.sequence && r.sequence < seq && sameRequest(w, r) && succeeded(r)));
|
|
7304
7322
|
for (const claim of claims.filter((c) => c.polarity === "success")) {
|
|
7305
|
-
const
|
|
7323
|
+
const via = claim.via !== void 0 ? ordered.find((c) => c.sequence === claim.via) : void 0, failed = unrecoveredBefore(claim.sequence, via)[0];
|
|
7306
7324
|
if (!failed || covered(via?.service ?? failed.service, "announce-after-failed-write")) continue;
|
|
7307
7325
|
out.push({
|
|
7308
7326
|
check: "announce-after-failed-write",
|
|
@@ -7349,7 +7367,7 @@ function genericChecks(calls, opts = {}) {
|
|
|
7349
7367
|
break;
|
|
7350
7368
|
}
|
|
7351
7369
|
}
|
|
7352
|
-
for (const failed of writes.filter((w) => FAILED.includes(w.outcome) && !(w.outcome === "timeout" && w.committed) && w.outcome !== "lost-response")) {
|
|
7370
|
+
for (const failed of writes.filter((w) => FAILED.includes(w.outcome) && !(w.outcome === "timeout" && w.committed) && w.outcome !== "lost-response" && !announcementSeqs.has(w.sequence) && !isAnnouncement(w) && !MESSAGING.test(w.path))) {
|
|
7353
7371
|
if (writes.some((r) => r.sequence > failed.sequence && sameRequest(failed, r) && succeeded(r))) continue;
|
|
7354
7372
|
const committed = writes.find((a) => a.sequence < failed.sequence && a.service !== failed.service && effects(a) > 0 && !announcementSeqs.has(a.sequence) && !isAnnouncement(a) && !writes.some((x) => x.sequence > failed.sequence && x.service === a.service && (x.resourceId ? x.resourceId === a.resourceId : x.resourcePath === a.resourcePath) && effects(x) > 0));
|
|
7355
7373
|
if (!committed || covered(committed.service, "partial-commit")) continue;
|
|
@@ -7407,9 +7425,14 @@ var displayName = (services, name) => {
|
|
|
7407
7425
|
};
|
|
7408
7426
|
var rowsOf = (state, service, path) => (state?.[service]?.[path] ?? []).filter((r) => !!r && typeof r === "object" && !Array.isArray(r));
|
|
7409
7427
|
var VOLATILE2 = /* @__PURE__ */ new Set(["id", "ts", "created", "created_at", "updated_at", "inserted_at", "createdAt", "updatedAt", "internalDate", "historyId", "threadId", "number", "iid", "latest_charge", "object", "sequence", "uuid"]);
|
|
7410
|
-
var volatileKey = (key2) => VOLATILE2.has(key2) || /_at$|At$/.test(key2);
|
|
7428
|
+
var volatileKey = (key2) => VOLATILE2.has(key2) || /_at$|At$/.test(key2) || /^(?:sid|guid|etag|uri|self|href)$/i.test(key2) || /^date_|_date$|^(?:created|updated|modified|sent)(?:_on|_time|_date)?$/i.test(key2) || /^(?:ending|starting|running|resulting)_?balance$|^balance_?after$/i.test(key2);
|
|
7411
7429
|
var canonical3 = (value) => Array.isArray(value) ? `[${value.map(canonical3).join(",")}]` : value && typeof value === "object" ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical3(value[k])}`).join(",")}}` : JSON.stringify(value ?? null);
|
|
7412
|
-
var contentSignature = (row
|
|
7430
|
+
var contentSignature = (row, collection) => {
|
|
7431
|
+
const type = (collection?.split("/").filter(Boolean).pop() ?? "").toLowerCase().replace(/[^a-z]/g, "").replace(/ies$/, "y").replace(/s$/, "");
|
|
7432
|
+
const ownId = (k) => !!type && k.toLowerCase().replace(/[^a-z]/g, "") === type + "id";
|
|
7433
|
+
const own = Object.entries(row).filter(([k, v]) => (volatileKey(k) || ownId(k)) && typeof v === "string" && v.length >= 6).map(([, v]) => v);
|
|
7434
|
+
return canonical3(Object.fromEntries(Object.entries(row).filter(([k, v]) => !volatileKey(k) && !ownId(k) && !own.some((id) => JSON.stringify(v ?? null).includes(id)))));
|
|
7435
|
+
};
|
|
7413
7436
|
function addedRows(initial, final) {
|
|
7414
7437
|
const rows2 = (list2) => list2.filter((r) => !!r && typeof r === "object" && !Array.isArray(r));
|
|
7415
7438
|
const ids = new Set(rows2(initial).map((r) => r.id).filter((id) => id !== void 0 && id !== null));
|
|
@@ -7448,6 +7471,7 @@ var stripeRefundOnce = {
|
|
|
7448
7471
|
title: "Each charge refunded at most once per request",
|
|
7449
7472
|
path: "/v1/refunds",
|
|
7450
7473
|
coversDuplicates: true,
|
|
7474
|
+
duplicatePaths: ["/v1/refunds"],
|
|
7451
7475
|
expected: "each charge refunded at most once for the same amount and reason; refund total \u2264 charge amount",
|
|
7452
7476
|
impact: "money",
|
|
7453
7477
|
impactHint: "duplicated refund amount is money paid out twice",
|
|
@@ -7482,6 +7506,7 @@ var stripeNoDuplicatePayment = {
|
|
|
7482
7506
|
title: "No duplicate charges, customers or subscriptions for one request",
|
|
7483
7507
|
path: "/v1/payment_intents",
|
|
7484
7508
|
coversDuplicates: true,
|
|
7509
|
+
duplicatePaths: ["/v1/payment_intents", "/v1/charges", "/v1/customers", "/v1/subscriptions"],
|
|
7485
7510
|
expected: "one payment intent per amount/currency/customer/payment method and one customer per email",
|
|
7486
7511
|
impact: "money",
|
|
7487
7512
|
impactHint: "a duplicated succeeded payment charges the customer twice",
|
|
@@ -7607,6 +7632,7 @@ function messageChecks(adapter, path) {
|
|
|
7607
7632
|
}
|
|
7608
7633
|
}];
|
|
7609
7634
|
}
|
|
7635
|
+
var TARGETED = /\bwhere\b[\s\S]*=\s*\$\d/i;
|
|
7610
7636
|
var postgresUpdateApplied = {
|
|
7611
7637
|
id: "postgres.update-applied",
|
|
7612
7638
|
title: "Updates the agent ran actually changed rows",
|
|
@@ -7615,7 +7641,7 @@ var postgresUpdateApplied = {
|
|
|
7615
7641
|
impact: "data-integrity",
|
|
7616
7642
|
impactHint: "the agent believes a record changed when it did not",
|
|
7617
7643
|
run(ctx) {
|
|
7618
|
-
return (ctx.database?.statements ?? []).filter((st) => /^
|
|
7644
|
+
return (ctx.database?.statements ?? []).filter((st) => st.count === 0 && (/^UPDATE$/i.test(st.command ?? "") || !ctx.duplicateDelivery && /^DELETE$/i.test(st.command ?? "") && TARGETED.test(st.text))).map((st) => {
|
|
7619
7645
|
const table2 = /^\s*(?:update|delete\s+from)\s+(?:only\s+)?"?([\w.]+)"?/i.exec(st.text)?.[1] ?? "a table";
|
|
7620
7646
|
return {
|
|
7621
7647
|
path: `/${table2}`,
|
|
@@ -7639,7 +7665,7 @@ var postgresNoDuplicateInsert = {
|
|
|
7639
7665
|
if (!ctx.database?.final) return out;
|
|
7640
7666
|
for (const table2 of ctx.database.final.tables) {
|
|
7641
7667
|
const before = ctx.database.initial.tables.find((t) => t.name === table2.name)?.rows ?? [];
|
|
7642
|
-
for (const group of groups(addedRows(before, table2.rows), contentSignature))
|
|
7668
|
+
for (const group of groups(addedRows(before, table2.rows), (r) => contentSignature(r, table2.name)))
|
|
7643
7669
|
out.push({
|
|
7644
7670
|
path: `/${table2.name}`,
|
|
7645
7671
|
actual: { table: table2.name, rows: group.length, row: group[0] },
|
|
@@ -7650,6 +7676,55 @@ var postgresNoDuplicateInsert = {
|
|
|
7650
7676
|
return out;
|
|
7651
7677
|
}
|
|
7652
7678
|
};
|
|
7679
|
+
var RELATIVE_SET = /\bset\b[\s\S]*?"?(\w+)"?\s*=\s*(?:"?\w+"?\.)?"?\1"?\s*[-+]/i;
|
|
7680
|
+
var postgresNoRepeatedRelativeUpdate = {
|
|
7681
|
+
id: "postgres.no-repeated-relative-update",
|
|
7682
|
+
title: "A redelivered trigger does not apply a balance change twice",
|
|
7683
|
+
path: "/",
|
|
7684
|
+
coversDuplicates: true,
|
|
7685
|
+
expected: "an UPDATE that adds to or subtracts from a value runs once when the same trigger arrives twice",
|
|
7686
|
+
impact: "money",
|
|
7687
|
+
impactHint: "credits, balances or counters change twice for one event",
|
|
7688
|
+
run(ctx) {
|
|
7689
|
+
if (!ctx.duplicateDelivery) return [];
|
|
7690
|
+
const applied = (ctx.database?.statements ?? []).filter((st) => /^UPDATE$/i.test(st.command ?? "") && (st.count ?? 0) > 0 && RELATIVE_SET.test(st.text));
|
|
7691
|
+
const byText = /* @__PURE__ */ new Map();
|
|
7692
|
+
for (const st of applied) byText.set(st.text, (byText.get(st.text) ?? 0) + 1);
|
|
7693
|
+
return [...byText].filter(([, n]) => n >= 2).map(([text2, n]) => {
|
|
7694
|
+
const table2 = /^\s*update\s+(?:only\s+)?"?([\w.]+)"?/i.exec(text2)?.[1] ?? "a table", column = RELATIVE_SET.exec(text2)?.[1] ?? "a value";
|
|
7695
|
+
return {
|
|
7696
|
+
path: `/${table2}`,
|
|
7697
|
+
actual: { statement: text2.slice(0, 200), applied: n },
|
|
7698
|
+
finding: `Your agent changed ${table2}.${column} ${times2(n)} when the same trigger was delivered twice`,
|
|
7699
|
+
impact: { count: n - 1 }
|
|
7700
|
+
};
|
|
7701
|
+
});
|
|
7702
|
+
}
|
|
7703
|
+
};
|
|
7704
|
+
var UNSCOPED = /^\s*(?:(delete\s+from|update)\s+(?:only\s+)?"?([\w.]+)"?(?![\s\S]*\bwhere\b)|(truncate)(?:\s+table)?\s+"?([\w.]+)"?|(drop)\s+(?:table|schema|database)\s+(?:if\s+exists\s+)?"?([\w.]+)"?)/i;
|
|
7705
|
+
var postgresNoUnscopedDestructive = {
|
|
7706
|
+
id: "postgres.no-unscoped-destructive",
|
|
7707
|
+
title: "No statement wipes or rewrites a whole table",
|
|
7708
|
+
path: "/",
|
|
7709
|
+
expected: "every DELETE and UPDATE is limited by a WHERE clause; no TRUNCATE or DROP",
|
|
7710
|
+
impact: "data-integrity",
|
|
7711
|
+
impactHint: "every row in the table is deleted or overwritten, not just the ones the action is about",
|
|
7712
|
+
run(ctx) {
|
|
7713
|
+
const out = [];
|
|
7714
|
+
for (const st of ctx.database?.statements ?? []) {
|
|
7715
|
+
const m = UNSCOPED.exec(st.text);
|
|
7716
|
+
if (!m) continue;
|
|
7717
|
+
const verb = (m[1] ?? m[3] ?? m[5]).toUpperCase().replace(/\s+FROM$/, ""), table2 = m[2] ?? m[4] ?? m[6];
|
|
7718
|
+
out.push({
|
|
7719
|
+
path: `/${table2}`,
|
|
7720
|
+
actual: { statement: st.text.slice(0, 200), rowsAffected: st.count ?? null },
|
|
7721
|
+
finding: verb === "DROP" ? `Your agent dropped ${table2}` : verb === "TRUNCATE" ? `Your agent emptied the whole ${table2} table` : `Your agent ran ${verb} on every row of ${table2} (no WHERE clause)`,
|
|
7722
|
+
impact: { count: 1 }
|
|
7723
|
+
});
|
|
7724
|
+
}
|
|
7725
|
+
return out;
|
|
7726
|
+
}
|
|
7727
|
+
};
|
|
7653
7728
|
var NOT_EFFECTS = /* @__PURE__ */ new Set(["openai", "anthropic", "google-oauth"]);
|
|
7654
7729
|
var genericRepeat = {
|
|
7655
7730
|
id: "generic.no-repeat-after-fault",
|
|
@@ -7660,11 +7735,13 @@ var genericRepeat = {
|
|
|
7660
7735
|
impactHint: "the same record exists twice downstream",
|
|
7661
7736
|
run(ctx) {
|
|
7662
7737
|
const s = ctx.service.name, out = [];
|
|
7663
|
-
|
|
7738
|
+
const covering = registryFor(ctx.service.adapter).filter((c) => c.coversDuplicates);
|
|
7739
|
+
if (NOT_EFFECTS.has(ctx.service.adapter ?? "") || covering.some((c) => !c.duplicatePaths)) return out;
|
|
7740
|
+
const judged = new Set(covering.flatMap((c) => c.duplicatePaths ?? []));
|
|
7664
7741
|
const faults = ctx.events.filter((e) => e.operation === "fault").map((e) => e.sequence);
|
|
7665
7742
|
if (!faults.length && !ctx.duplicateDelivery) return out;
|
|
7666
|
-
for (const path of Object.keys(ctx.finalState?.[s] ?? {})) {
|
|
7667
|
-
for (const group of groups(addedRows(rowsOf(ctx.initialState, s, path), rowsOf(ctx.finalState, s, path)), contentSignature)) {
|
|
7743
|
+
for (const path of Object.keys(ctx.finalState?.[s] ?? {}).filter((p) => !judged.has(p))) {
|
|
7744
|
+
for (const group of groups(addedRows(rowsOf(ctx.initialState, s, path), rowsOf(ctx.finalState, s, path)), (r) => contentSignature(r, path))) {
|
|
7668
7745
|
const seq = writeSequences(ctx, s, group.map((r) => r.id));
|
|
7669
7746
|
if (!ctx.duplicateDelivery && seq.length && !faults.some((f) => f < Math.max(...seq))) continue;
|
|
7670
7747
|
const label2 = path.split("/").filter(Boolean).pop() ?? "record";
|
|
@@ -7684,7 +7761,7 @@ var DEFAULT_CHECKS = {
|
|
|
7684
7761
|
stripe: [stripeRefundOnce, stripeNoDuplicatePayment, stripeIdempotentRetries],
|
|
7685
7762
|
slack: messageChecks("slack", "/messages"),
|
|
7686
7763
|
gmail: messageChecks("gmail", "/gmail/v1/users/me/messages"),
|
|
7687
|
-
postgres: [postgresUpdateApplied, postgresNoDuplicateInsert],
|
|
7764
|
+
postgres: [postgresUpdateApplied, postgresNoDuplicateInsert, postgresNoRepeatedRelativeUpdate, postgresNoUnscopedDestructive],
|
|
7688
7765
|
"*": [genericRepeat]
|
|
7689
7766
|
};
|
|
7690
7767
|
var VENDOR_COVERS = { "retry-without-key": /\.idempotent-retries$/, "announce-after-failed-write": /\.announce-after-success$/ };
|
|
@@ -7698,7 +7775,7 @@ function defaultChecksFor(services, opts = {}) {
|
|
|
7698
7775
|
}
|
|
7699
7776
|
function runDefaultChecks(input) {
|
|
7700
7777
|
const services = input.spec.services.map((s) => ({ name: s.name, adapter: s.adapter ?? "json-collection", collections: s.collections }));
|
|
7701
|
-
return defaultChecksFor(services, { postgres: !!input.database
|
|
7778
|
+
return defaultChecksFor(services, { postgres: !!input.database }).map(({ service, check }) => {
|
|
7702
7779
|
const violations = check.run({ service, services, initialState: input.initialState, finalState: input.finalState, events: input.events, fault: input.fault, database: input.database, duplicateDelivery: input.duplicateDelivery });
|
|
7703
7780
|
const base = { id: `default.${check.id}.${service.name}`, kind: "default", check: check.id, title: check.title, service: service.name, expected: check.expected };
|
|
7704
7781
|
if (!violations.length) return { ...base, path: check.path, passed: true, actual: "no violations" };
|