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
5 changes: 5 additions & 0 deletions evidence/regex-gate-embed/bun-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ npm install --prefix /tmp/regex-gate-bun-1.4.0 --no-package-lock bun@1.4.0

added 2 packages in 1s

exit: 0
17 changes: 17 additions & 0 deletions evidence/regex-gate-embed/check-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$ cd packages/sdk && npx vitest run tests/named-gate-engine.test.ts tests/named-gate-diagnostics.test.ts tests/artifact-gates.test.ts tests/gate-contract.test.ts tests/preflight.test.ts

RUN v2.1.9 /home/daytona/.relayflow-v2-supervisor/durable/repository/packages/sdk

✓ tests/named-gate-diagnostics.test.ts (20 tests) 817ms
✓ tests/artifact-gates.test.ts (27 tests) 315ms
✓ tests/named-gate-engine.test.ts (2 tests) 299ms
✓ tests/preflight.test.ts (70 tests) 89ms
✓ tests/gate-contract.test.ts (20 tests) 105ms

Test Files 5 passed (5)
Tests 139 passed (139)
Start at 18:18:20
Duration 3.03s (transform 2.25s, setup 43ms, collect 5.74s, tests 1.63s, environment 1ms, prepare 258ms)


exit: 0
3 changes: 3 additions & 0 deletions evidence/regex-gate-embed/check-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ cd packages/sdk && npx tsc --noEmit

exit: 0
7 changes: 7 additions & 0 deletions evidence/regex-gate-embed/check-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$ cd packages/sdk && npm run build

> @relayflows/sdk@2.0.42 build
> tsc && node scripts/make-cli-executable.mjs


exit: 0
4 changes: 4 additions & 0 deletions evidence/regex-gate-embed/check-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ node scripts/generate-re2js-embed.mjs --check
re2js 2.8.6 embed is current

exit: 0
4 changes: 4 additions & 0 deletions evidence/regex-gate-embed/check-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ npm view bun@1.4.0 version
1.4.0

exit: 0
8 changes: 8 additions & 0 deletions evidence/regex-gate-embed/generate-again.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$ npm run gen:re2js --prefix packages/sdk

> @relayflows/sdk@2.0.42 gen:re2js
> node ../../scripts/generate-re2js-embed.mjs

re2js 2.8.6 embed is current

exit: 0
130 changes: 130 additions & 0 deletions evidence/regex-gate-embed/kernel-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
$ cd kernel && sh ../ops/cargo.sh build
Compiling proc-macro2 v1.0.107
Compiling quote v1.0.47
Compiling unicode-ident v1.0.24
Compiling stable_deref_trait v1.2.1
Compiling libc v0.2.189
Compiling version_check v0.9.5
Compiling autocfg v1.5.1
Compiling cfg-if v1.0.4
Compiling serde_core v1.0.229
Compiling num-traits v0.2.19
Compiling getrandom v0.3.4
Compiling zerocopy v0.8.56
Compiling syn v3.0.4
Compiling syn v2.0.119
Compiling serde v1.0.229
Compiling smallvec v1.15.2
Compiling synstructure v0.13.2
Compiling memchr v2.8.3
Compiling zerofrom-derive v0.1.7
Compiling yoke-derive v0.8.2
Compiling zerofrom v0.1.8
Compiling writeable v0.6.4
Compiling litemap v0.8.3
Compiling num-integer v0.1.47
Compiling yoke v0.8.3
Compiling generic-array v0.14.7
Compiling icu_normalizer_data v2.3.0
Compiling icu_properties_data v2.3.0
Compiling utf8_iter v1.0.4
Compiling typenum v1.20.1
Compiling ref-cast v1.0.27
Compiling zerovec-derive v0.11.6
Compiling displaydoc v0.2.7
Compiling serde_derive v1.0.229
Compiling parking_lot_core v0.9.12
Compiling zerotrie v0.2.5
Compiling zmij v1.0.23
Compiling zerovec v0.11.8
Compiling ref-cast-impl v1.0.27
Compiling num-bigint v0.4.8
Compiling tinystr v0.8.4
Compiling potential_utf v0.1.6
Compiling icu_locale_core v2.3.0
Compiling icu_collections v2.3.0
Compiling aho-corasick v1.1.5
Compiling icu_provider v2.3.1
Compiling ahash v0.8.12
Compiling find-msvc-tools v0.1.11
Compiling serde_json v1.0.151
Compiling scopeguard v1.2.0
Compiling regex-syntax v0.8.11
Compiling shlex v2.0.1
Compiling cc v1.4.4
Compiling lock_api v0.4.14
Compiling icu_normalizer v2.3.0
Compiling icu_properties v2.3.0
Compiling num-rational v0.4.2
Compiling regex-automata v0.4.18
Compiling ppv-lite86 v0.2.21
Compiling num-iter v0.1.46
Compiling rand_core v0.9.5
Compiling num-complex v0.4.6
Compiling vcpkg v0.2.15
Compiling borrow-or-share v0.2.4
Compiling once_cell v1.21.4
Compiling bit-vec v0.8.0
Compiling pkg-config v0.3.34
Compiling itoa v1.0.18
Compiling bit-set v0.8.0
Compiling libsqlite3-sys v0.35.0
Compiling fluent-uri v0.3.2
Compiling num v0.4.3
Compiling rand_chacha v0.9.0
Compiling idna_adapter v1.2.2
Compiling parking_lot v0.12.5
Compiling crypto-common v0.1.7
Compiling block-buffer v0.10.4
Compiling lazy_static v1.5.0
Compiling thiserror v2.0.20
Compiling vsimd v0.8.0
Compiling outref v0.5.2
Compiling foldhash v0.1.5
Compiling percent-encoding v2.3.2
Compiling utf8parse v0.2.2
Compiling uuid v1.26.0
Compiling anstyle-parse v1.0.0
Compiling referencing v0.33.0
Compiling regex v1.13.1
Compiling uuid-simd v0.8.0
Compiling fancy-regex v0.16.2
Compiling hashbrown v0.15.5
Compiling fraction v0.15.4
Compiling digest v0.10.7
Compiling idna v1.1.0
Compiling rand v0.9.5
Compiling email_address v0.2.9
Compiling thiserror-impl v2.0.20
Compiling base64 v0.22.1
Compiling colorchoice v1.0.5
Compiling anstyle v1.0.14
Compiling bytecount v0.6.9
Compiling cpufeatures v0.2.17
Compiling is_terminal_polyfill v1.70.2
Compiling anstyle-query v1.1.5
Compiling num-cmp v0.1.0
Compiling anstream v1.0.0
Compiling jsonschema v0.33.0
Compiling sha2 v0.10.9
Compiling ulid v1.2.1
Compiling hashlink v0.10.0
Compiling bitflags v2.13.1
Compiling strsim v0.11.1
Compiling anyhow v1.0.104
Compiling clap_lex v1.1.0
Compiling fallible-streaming-iterator v0.1.9
Compiling fallible-iterator v0.3.0
Compiling ryu-js v1.0.3
Compiling heck v0.5.0
Compiling clap_builder v4.6.6
Compiling clap_derive v4.6.4
Compiling relayflowd-core v0.1.0 (/home/daytona/.relayflow-v2-supervisor/durable/repository/kernel/relayflowd-core)
Compiling clap v4.6.6
Compiling wait-timeout v0.2.1
Compiling rusqlite v0.37.0
Compiling relayflowd-journal v0.1.0 (/home/daytona/.relayflow-v2-supervisor/durable/repository/kernel/relayflowd-journal)
Compiling relayflowd v0.1.0 (/home/daytona/.relayflow-v2-supervisor/durable/repository/kernel/relayflowd)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 13.55s

exit: 0
32 changes: 32 additions & 0 deletions evidence/regex-gate-embed/live-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$ cd packages/sdk && FLOWS_BUILD_BUN=/tmp/regex-gate-bun-1.4.0/node_modules/.bin/bun RELAYFLOWD_BIN=/home/daytona/.relayflows-toolchain/target/2962130851/debug/relayflowd npx vitest run tests/authored-node-runtime.test.ts tests/named-gate-journal.test.ts

RUN v2.1.9 /home/daytona/.relayflow-v2-supervisor/durable/repository/packages/sdk

✓ tests/named-gate-journal.test.ts (5 tests) 1445ms
✓ a lowered subprocess_gate journals the gate command's streams > persists what the gate printed before a timeout killed it 801ms
✓ a gate on an agent step > journals the command's streams and surfaces them in the authored failure 450ms
✓ tests/authored-node-runtime.test.ts (16 tests) 29692ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > serializes the immutable prepared binding facts through the Node and CLI boundary 1132ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > suppresses the loader warning while preserving authored experimental warnings 1160ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > awaits agent plus three run steps and resumes without repeating effects 1801ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > accepts a predicate-gated flow: the `<step>.gate` child is journaled, verified, and not counted as an authored step 1659ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > resumes a run killed mid-step: the retried child passes the durable result verifier 2142ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > parks an f.human across the IPC boundary, answers it, and resumes the Node body with the answer 2527ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > stops on parent SIGKILL and replays completed children before success 2552ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > stops on parent SIGTERM and replays completed children before success 2467ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > stops on parent blocked-SIGKILL and replays completed children before success 2432ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > stops on parent SIGKILL and replays completed children before declined 2505ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > refuses unawaited rather than reporting terminal success 1250ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > refuses manual then rather than reporting terminal success 1313ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > dispatches the captured child graph even when the source changes before execution 1222ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > rejects a forged result frame without durable completion 1160ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > refuses missing Node before body effects or root admission 500ms
✓ Bun 1.4.0 standalone → native Node authored lifecycle > refuses an old Node candidate before body effects 527ms

Test Files 2 passed (2)
Tests 21 passed (21)
Start at 18:19:01
Duration 30.79s (transform 803ms, setup 33ms, collect 1.94s, tests 31.14s, environment 0ms, prepare 57ms)


exit: 0
13 changes: 13 additions & 0 deletions evidence/regex-gate-embed/mutation-restore.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- reverted/named-gate-lowering.ts
+++ restored/named-gate-lowering.ts
@@ -1,3 +1 @@
-import { readFileSync } from 'node:fs';
-import { createRequire } from 'node:module';
-import { deflateRawSync } from 'node:zlib';
+import { RE2JS_DEFLATED_BASE64 } from './re2js-embedded.js';
@@ -9 +6,0 @@
-let re2Source: string | undefined;
@@ -13,2 +10 @@
- re2Source ??= deflateRawSync(readFileSync(createRequire(import.meta.url).resolve('re2js'))).toString('base64');
- return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(re2Source)},'base64')).toString())(re2);`;
+ return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(RE2JS_DEFLATED_BASE64)},'base64')).toString())(re2);`;
13 changes: 13 additions & 0 deletions evidence/regex-gate-embed/mutation-restored.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ cd packages/sdk && npx vitest run tests/named-gate-engine.test.ts -t "lowers and executes"

RUN v2.1.9 /home/daytona/.relayflow-v2-supervisor/durable/repository/packages/sdk

✓ tests/named-gate-engine.test.ts (2 tests | 1 skipped) 134ms

Test Files 1 passed (1)
Tests 1 passed | 1 skipped (2)
Start at 18:18:47
Duration 299ms (transform 38ms, setup 14ms, collect 39ms, tests 134ms, environment 0ms, prepare 30ms)


exit: 0
13 changes: 13 additions & 0 deletions evidence/regex-gate-embed/mutation-revert.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- fixed/named-gate-lowering.ts
+++ reverted/named-gate-lowering.ts
@@ -1 +1,3 @@
-import { RE2JS_DEFLATED_BASE64 } from './re2js-embedded.js';
+import { readFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { deflateRawSync } from 'node:zlib';
@@ -6,0 +9 @@
+let re2Source: string | undefined;
@@ -10 +13,2 @@
- return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(RE2JS_DEFLATED_BASE64)},'base64')).toString())(re2);`;
+ re2Source ??= deflateRawSync(readFileSync(createRequire(import.meta.url).resolve('re2js'))).toString('base64');
+ return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(re2Source)},'base64')).toString())(re2);`;
82 changes: 82 additions & 0 deletions evidence/regex-gate-embed/mutation-reverted.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
$ cd packages/sdk && npx vitest run tests/named-gate-engine.test.ts -t "lowers and executes"

RUN v2.1.9 /home/daytona/.relayflow-v2-supervisor/durable/repository/packages/sdk

❯ tests/named-gate-engine.test.ts (2 tests | 1 failed | 1 skipped) 79ms
× lowers and executes a bundled regex gate without package resolution 78ms
→ node:internal/modules/cjs/loader:1453
const err = new Error(message);
^

Error: Cannot find module 're2js'
Require stack:
- /tmp/named-gate-engine-cBM0KV/bundle.mjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1453:15)
at require.resolve (node:internal/modules/helpers:163:19)
at embeddedRE2 (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6331:76)
at gateCommand (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6423:17)
at lowerNamedGates (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6365:16)
at file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6474:13
at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:655:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/tmp/named-gate-engine-cBM0KV/bundle.mjs' ]
}

Node.js v25.6.0
: expected 1 to be +0 // Object.is equality

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

FAIL tests/named-gate-engine.test.ts > lowers and executes a bundled regex gate without package resolution
AssertionError: node:internal/modules/cjs/loader:1453
const err = new Error(message);
^

Error: Cannot find module 're2js'
Require stack:
- /tmp/named-gate-engine-cBM0KV/bundle.mjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1453:15)
at require.resolve (node:internal/modules/helpers:163:19)
at embeddedRE2 (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6331:76)
at gateCommand (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6423:17)
at lowerNamedGates (file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6365:16)
at file:///tmp/named-gate-engine-cBM0KV/bundle.mjs:6474:13
at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:655:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/tmp/named-gate-engine-cBM0KV/bundle.mjs' ]
}

Node.js v25.6.0
: expected 1 to be +0 // Object.is equality

- Expected
+ Received

- 0
+ 1

❯ embeddedRE2 ../../../../../../../tmp/named-gate-engine-cBM0KV/bundle.mjs:6331:76
❯ gateCommand ../../../../../../../tmp/named-gate-engine-cBM0KV/bundle.mjs:6423:17
❯ lowerNamedGates ../../../../../../../tmp/named-gate-engine-cBM0KV/bundle.mjs:6365:16
❯ ../../../../../../../tmp/named-gate-engine-cBM0KV/bundle.mjs:6474:13
❯ tests/named-gate-engine.test.ts:54:44
52| const env = { ...process.env, NODE_PATH: '' };
53| const lowered = spawnSync(process.execPath, [bundle], { cwd: direc…
54| expect(lowered.status, lowered.stderr).toBe(0);
| ^
55| const command = lowered.stdout.trim();
56| expect(command).toMatch(/^node -e /);

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files 1 failed (1)
Tests 1 failed | 1 skipped (2)
Start at 18:18:47
Duration 240ms (transform 36ms, setup 15ms, collect 32ms, tests 79ms, environment 0ms, prepare 32ms)


exit: 1
4 changes: 4 additions & 0 deletions evidence/regex-gate-embed/version-restored.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ node scripts/generate-re2js-embed.mjs --check
re2js 2.8.6 embed is current

exit: 0
4 changes: 4 additions & 0 deletions evidence/regex-gate-embed/version-stale.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ node scripts/generate-re2js-embed.mjs --check
re2js embed is stale; run npm run gen:re2js --prefix packages/sdk

exit: 1
2 changes: 1 addition & 1 deletion packages/sdk/package-lock.json

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

3 changes: 2 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"src"
],
"scripts": {
"gen:re2js": "node ../../scripts/generate-re2js-embed.mjs",
"build": "tsc && node scripts/make-cli-executable.mjs",
"demo:hn": "npm run build && node dist/demo-hn-monitor.js",
"prepare": "npm run build",
Expand All @@ -56,7 +57,7 @@
"ajv": "^8.17.1",
"ajv-draft-04": "^1.0.0",
"js-yaml": "^5.4.1",
"re2js": "^2.8.6",
"re2js": "2.8.6",
"typescript": "^5.6.0",
"undici": "^7.29.1",
"yaml": "^2.5.1"
Expand Down
8 changes: 2 additions & 6 deletions packages/sdk/src/named-gate-lowering.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { deflateRawSync } from 'node:zlib';
import { RE2JS_DEFLATED_BASE64 } from './re2js-embedded.js';
import { bindingDependencies } from './input-binding.js';
import { isNamedGate, regexFlags } from './named-gates.js';
import type { NamedDataGate, StepSpec, VerificationSpec } from './spec.js';

const quote = (text: string): string => `'${text.replaceAll("'", "'\\''")}'`;
let re2Source: string | undefined;

/** Embed the pinned engine in the command: execution does not resolve npm or SDK paths. */
function embeddedRE2(): string {
re2Source ??= deflateRawSync(readFileSync(createRequire(import.meta.url).resolve('re2js'))).toString('base64');
return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(re2Source)},'base64')).toString())(re2);`;
return `const re2={};new Function('exports',require('node:zlib').inflateRawSync(Buffer.from(${JSON.stringify(RE2JS_DEFLATED_BASE64)},'base64')).toString())(re2);`;
}

/**
Expand Down
Loading
Loading