Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@cloudflare/workers-oauth-provider": "1.2.4",
"@hono/node-server": "1.19.9",
"@hono/valibot-validator": "0.6.1",
"@mastra/core": "1.81.0",
"@mastra/core": "1.84.0",
"@modelcontextprotocol/server": "2.3.1",
"@simple-agent-manager/agent-email": "workspace:*",
"@simple-agent-manager/ai-proxy": "workspace:*",
Expand All @@ -44,7 +44,7 @@
"@simple-agent-manager/shared": "workspace:*",
"@simple-agent-manager/worker-core": "workspace:*",
"@valibot/to-json-schema": "catalog:",
"ai": "7.0.137",
"ai": "7.0.173",
"better-auth": "catalog:",
"better-auth-cloudflare": "0.3.1",
"drizzle-orm": "catalog:",
Expand Down
13 changes: 12 additions & 1 deletion apps/api/tests/integration/runtime-secret-requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,17 @@ describe('hardening', () => {
const firstHeld = new Promise<void>((resolve) => {
releaseFirst = resolve;
});
let firstBatchEntered!: () => void;
const firstAtBatch = new Promise<void>((resolve) => {
firstBatchEntered = resolve;
});
let batches = 0;
let firstRan: Promise<unknown> = Promise.resolve();
env.DATABASE.batch = (async (statements: D1PreparedStatement[]) => {
batches += 1;
if (batches === 1) {
firstRan = firstHeld.then(() => realBatch(statements));
firstBatchEntered();
return firstRan;
}
// Second submit: both have now passed every pre-check. Run the first transaction, then this.
Expand All @@ -768,8 +773,14 @@ describe('hardening', () => {
return realBatch(statements);
}) as typeof env.DATABASE.batch;

const firstSubmit = fulfill(request.id, { value: SENTINEL });
// Async encryption can reorder batch arrival. Hold the first request at its
// transaction before starting the second, while both still read pending.
await firstAtBatch;
expect(requestRow(request.id)?.status).toBe('pending');
expect(envRow('STRIPE_API_KEY')).toBeUndefined();
const [first, second] = await Promise.all([
fulfill(request.id, { value: SENTINEL }),
firstSubmit,
fulfill(request.id, { value: OTHER_SENTINEL }),
]);
expect(batches).toBe(2);
Expand Down
134 changes: 51 additions & 83 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading