Skip to content

Commit 60488ef

Browse files
committed
test(runtime): run the hook capability refusal pin on SQLite; ratchet the unpinned-status baseline
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5o5GCE3vGxq6G24dZu
1 parent 2f1dace commit 60488ef

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎packages/runtime/src/sandbox/hook-capability-denial-is-a-refusal.integration.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525
* - An ACTION body's denial keeps the #4431 fault contract
2626
* (`capability-denial-is-a-fault.test.ts`); this card ruled on hooks only.
2727
*
28-
* Measured in composition — a real `ObjectQL`, a real driver, the real
28+
* Measured in composition — a real `ObjectQL`, a real SQLite driver, the real
2929
* `QuickJSScriptRunner` and hook wrapper — and read off `mapDataError`, the
3030
* ADR-0112 table every data door answers with.
3131
*/
3232

3333
import { describe, it, expect, afterEach } from 'vitest';
34+
import { mkdtempSync, rmSync } from 'node:fs';
35+
import { tmpdir } from 'node:os';
36+
import { join } from 'node:path';
3437
import { mapDataError } from '@objectstack/types';
3538
import { ObjectQL, bindHooksToEngine } from '@objectstack/objectql';
36-
import { InMemoryDriver } from '@objectstack/driver-memory';
39+
import { SqlDriver } from '@objectstack/driver-sql';
3740
import { hookBodyRunnerFactory } from './body-runner.js';
3841
import { QuickJSScriptRunner } from './quickjs-runner.js';
3942

@@ -73,17 +76,22 @@ const GATES = [
7376

7477
describe('[#26903] a hook body\'s capability denial is a coded refusal', () => {
7578
let engine: ObjectQL | null = null;
79+
let dir: string | null = null;
7680

7781
afterEach(async () => {
7882
try { await engine?.destroy(); } catch { /* noop */ }
7983
engine = null;
84+
if (dir) { rmSync(dir, { recursive: true, force: true }); dir = null; }
8085
});
8186

8287
async function boot(hook: Record<string, unknown>) {
8388
const hookLog = recordingLogger();
8489
const bodyLog = recordingLogger();
90+
dir = mkdtempSync(join(tmpdir(), 'os-hook-cap-26903-'));
91+
const driver = new SqlDriver({ client: 'better-sqlite3', connection: { filename: join(dir, 'data.sqlite') }, useNullAsDefault: true });
92+
await driver.initObjects([NOTE, LOG]);
8593
engine = new ObjectQL();
86-
engine.registerDriver(new InMemoryDriver() as any, true);
94+
engine.registerDriver(driver as any, true);
8795
await engine.init();
8896
for (const o of [NOTE, LOG]) engine.registry.registerObject(o as any);
8997
const bodyRunner = hookBodyRunnerFactory(new QuickJSScriptRunner(), { ql: engine, appId: 'cap', logger: bodyLog });

‎scripts/error-status-unpinned-baseline.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"EXPIRED_TOKEN",
88
"FIELD_NOT_ACCESSIBLE",
99
"FIELD_NOT_FOUND",
10-
"INSUFFICIENT_PRIVILEGES",
1110
"INTEGRATION_ERROR",
1211
"INVALID_CREDENTIALS",
1312
"INVALID_FORMAT",

0 commit comments

Comments
 (0)