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
385 changes: 385 additions & 0 deletions ops/RUNTIME-STATUS.md

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions ops/local-work-package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// The smallest useful local drive package: a mechanical change from BACKLOG.
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { createHash } from 'node:crypto';
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { dirname } from 'node:path';
import { randomUUID } from 'node:crypto';

const target = 'packages/sdk/src/compile.ts';
const packagePath = '.relayflow/drive-local/package.json';
const oldName = 'validateKernelRetry';
const newName = 'validateAuthoringRetryDefaults';
const hash = text => createHash('sha256').update(text).digest('hex');
const read = path => readFileSync(path, 'utf8');
const git = (...args) => execFileSync('git', args, { encoding: 'utf8' }).trim();

// A killed writer leaves the destination wholly old or wholly new. Flush the
// replacement before rename and the containing directory before reporting it.
function writeAtomically(path, contents) {
const temporary = `${path}.${randomUUID()}.tmp`;
try {
const mode = path === target ? statSync(path).mode & 0o777 : 0o600;
writeFileSync(temporary, contents, { flag: 'wx', mode, flush: true });
renameSync(temporary, path);
const directory = openSync(dirname(path), 'r');
try { fsyncSync(directory); } finally { closeSync(directory); }
} finally { rmSync(temporary, { force: true }); }
}

switch (process.argv[2]) {
case 'select': {
const branch = git('branch', '--show-current');
assert(branch && branch !== 'main', 'LOCAL_DRIVE_REFUSED: use a work branch');
assert.equal(git('status', '--porcelain', '--', target), '', 'LOCAL_DRIVE_REFUSED: target has uncommitted edits');
const entry = read('ops/BACKLOG.md').match(/^- \*\*F8b\*\*[^\n]*(?:\n [^\n]*)*/m)?.[0];
assert(entry?.includes(oldName), 'BACKLOG_F8B_MISSING: expected the recorded work item');
const source = read(target);
assert.equal(source.split(oldName).length - 1, 2, 'PACKAGE_ALREADY_APPLIED_OR_CHANGED: expected declaration and call');
const work = { id: 'F8b', entry, branch, target, before: hash(source), after: hash(source.replaceAll(oldName, newName)) };
mkdirSync('.relayflow/drive-local', { recursive: true });
writeAtomically(packagePath, JSON.stringify(work, null, 2) + '\n');
assert.equal(JSON.parse(read(packagePath)).before, work.before);
console.log(JSON.stringify(work));
break;
}
case 'apply': {
const work = JSON.parse(read(packagePath));
assert.equal(git('branch', '--show-current'), work.branch, 'work branch changed');
const before = read(target);
// A retry after an interrupted write can observe the exact intended end state.
if (hash(before) === work.after) { console.log('PACKAGE_ALREADY_APPLIED: F8b'); break; }
assert.equal(hash(before), work.before, 'TARGET_CHANGED: refusing to overwrite intervening work');
const after = before.replaceAll(oldName, newName);
assert.notEqual(after, before);
writeAtomically(target, after);
assert.equal(hash(read(target)), work.after, 'MUTATION_NOT_PERSISTED');
console.log(`PACKAGE_APPLIED: F8b ${work.before} -> ${work.after}`);
console.log(git('diff', '--', target));
break;
}
case 'report': {
const work = JSON.parse(read(packagePath));
assert.equal(hash(read(target)), work.after, 'TARGET_CHANGED: expected the applied package');
const diff = git('diff', '--', target);
assert(diff.includes(`+function ${newName}(`), 'PACKAGE_DIFF_MISSING');
console.log('PACKAGE_EXECUTED: F8b; delivery requires a branch commit and human-reviewed PR.');
console.log(diff);
break;
}
default: throw new Error('Usage: node ops/local-work-package.mjs <select|apply|report>');
}
53 changes: 53 additions & 0 deletions ops/local-work-package.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import assert from 'node:assert/strict';
import { spawnSync, execFileSync } from 'node:child_process';
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import test from 'node:test';

const script = resolve('ops/local-work-package.mjs');

test('interrupted package write preserves the original and retry applies once', t => {
const root = mkdtempSync(join(tmpdir(), 'local-package-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
const git = (...args) => execFileSync('git', args, { cwd: root, stdio: 'pipe' });
git('init', '-q', '-b', 'work');
mkdirSync(join(root, 'packages/sdk/src'), { recursive: true });
mkdirSync(join(root, 'ops'));
const target = join(root, 'packages/sdk/src/compile.ts');
const original = 'function validateKernelRetry() {}\nvalidateKernelRetry();\n';
writeFileSync(target, original);
writeFileSync(join(root, 'ops/BACKLOG.md'), '- **F8b** — rename `validateKernelRetry`\n');
git('add', '.');
git('-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.test',
'-c', 'commit.gpgsign=false', 'commit', '-qm', 'fixture');
const run = (operation, extra = []) => spawnSync(process.execPath, [...extra, script, operation],
{ cwd: root, encoding: 'utf8', timeout: 5000 });
const selected = run('select');
assert.equal(selected.status, 0, selected.stderr);
// Intercept the real fs write in a separate process, write a partial prefix,
// then SIGKILL before rename. Never change the package implementation.
const hook = join(root, 'interrupt.cjs');
writeFileSync(hook, `const fs = require('node:fs');
const write = fs.writeFileSync;
fs.writeFileSync = (path, data, options) => {
if (String(path).includes('compile.ts') && String(path).endsWith('.tmp')) {
write(path, data.slice(0, 9), options);
process.kill(process.pid, 'SIGKILL');
}
return write(path, data, options);
};
require('node:module').syncBuiltinESMExports();
`);
const interrupted = run('apply', ['--require', hook]);
assert.equal(interrupted.signal, 'SIGKILL', interrupted.stderr);
assert.equal(readFileSync(target, 'utf8'), original);
const applied = run('apply');
assert.equal(applied.status, 0, applied.stderr);
const expected = original.replaceAll('validateKernelRetry', 'validateAuthoringRetryDefaults');
assert.equal(readFileSync(target, 'utf8'), expected);
const retry = run('apply');
assert.equal(retry.status, 0, retry.stderr);
assert.match(retry.stdout, /PACKAGE_ALREADY_APPLIED/);
assert.equal(readFileSync(target, 'utf8'), expected);
});
250 changes: 250 additions & 0 deletions ops/runtime-evidence/build-kernel.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
Updating crates.io index
Downloading crates ...
Downloaded heck v0.5.0
Downloaded idna_adapter v1.2.2
Downloaded itoa v1.0.18
Downloaded outref v0.5.2
Downloaded percent-encoding v2.3.2
Downloaded tinystr v0.8.4
Downloaded num v0.4.3
Downloaded ulid v1.2.1
Downloaded zerofrom v0.1.8
Downloaded crypto-common v0.1.7
Downloaded bit-set v0.8.0
Downloaded block-buffer v0.10.4
Downloaded colorchoice v1.0.5
Downloaded potential_utf v0.1.6
Downloaded strsim v0.11.1
Downloaded autocfg v1.5.1
Downloaded bit-vec v0.8.0
Downloaded cpufeatures v0.2.17
Downloaded find-msvc-tools v0.1.11
Downloaded utf8_iter v1.0.4
Downloaded yoke-derive v0.8.2
Downloaded uuid-simd v0.8.0
Downloaded zerofrom-derive v0.1.7
Downloaded yoke v0.8.3
Downloaded fallible-streaming-iterator v0.1.9
Downloaded generic-array v0.14.7
Downloaded utf8parse v0.2.2
Downloaded borrow-or-share v0.2.4
Downloaded clap_lex v1.1.0
Downloaded wait-timeout v0.2.1
Downloaded writeable v0.6.4
Downloaded fallible-iterator v0.3.0
Downloaded zmij v1.0.23
Downloaded ref-cast v1.0.27
Downloaded stable_deref_trait v1.2.1
Downloaded is_terminal_polyfill v1.70.2
Downloaded num-cmp v0.1.0
Downloaded num-iter v0.1.46
Downloaded version_check v0.9.5
Downloaded vsimd v0.8.0
Downloaded zerovec-derive v0.11.6
Downloaded unicode-ident v1.0.24
Downloaded uuid v1.26.0
Downloaded zerotrie v0.2.5
Downloaded typenum v1.20.1
Downloaded zerovec v0.11.8
Downloaded anstyle-query v1.1.5
Downloaded bytecount v0.6.9
Downloaded cfg-if v1.0.4
Downloaded displaydoc v0.2.7
Downloaded foldhash v0.1.5
Downloaded hashlink v0.10.0
Downloaded pkg-config v0.3.34
Downloaded ppv-lite86 v0.2.21
Downloaded quote v1.0.47
Downloaded rand_chacha v0.9.0
Downloaded rand_core v0.9.5
Downloaded ref-cast-impl v1.0.27
Downloaded referencing v0.33.0
Downloaded scopeguard v1.2.0
Downloaded sha2 v0.10.9
Downloaded shlex v2.0.1
Downloaded synstructure v0.13.2
Downloaded thiserror-impl v2.0.20
Downloaded anstream v1.0.0
Downloaded anstyle v1.0.14
Downloaded anstyle-parse v1.0.0
Downloaded anyhow v1.0.104
Downloaded bitflags v2.13.1
Downloaded clap_derive v4.6.4
Downloaded digest v0.10.7
Downloaded email_address v0.2.9
Downloaded fluent-uri v0.3.2
Downloaded lock_api v0.4.14
Downloaded num-complex v0.4.6
Downloaded num-integer v0.1.47
Downloaded num-rational v0.4.2
Downloaded lazy_static v1.5.0
Downloaded ahash v0.8.12
Downloaded icu_provider v2.3.1
Downloaded vcpkg v0.2.15
Downloaded zerocopy v0.8.56
Downloaded litemap v0.8.3
Downloaded thiserror v2.0.20
Downloaded clap v4.6.6
Downloaded getrandom v0.3.4
Downloaded smallvec v1.15.2
Downloaded icu_locale_core v2.3.0
Downloaded parking_lot_core v0.9.12
Downloaded num-traits v0.2.19
Downloaded proc-macro2 v1.0.107
Downloaded parking_lot v0.12.5
Downloaded icu_normalizer_data v2.3.0
Downloaded cc v1.4.4
Downloaded serde v1.0.229
Downloaded serde_core v1.0.229
Downloaded once_cell v1.21.4
Downloaded serde_derive v1.0.229
Downloaded icu_collections v2.3.0
Downloaded base64 v0.22.1
Downloaded icu_properties v2.3.0
Downloaded fraction v0.15.4
Downloaded memchr v2.8.3
Downloaded rand v0.9.5
Downloaded aho-corasick v1.1.5
Downloaded fancy-regex v0.16.2
Downloaded num-bigint v0.4.8
Downloaded jsonschema v0.33.0
Downloaded hashbrown v0.15.5
Downloaded serde_json v1.0.151
Downloaded idna v1.1.0
Downloaded icu_properties_data v2.3.0
Downloaded regex v1.13.1
Downloaded rusqlite v0.37.0
Downloaded clap_builder v4.6.6
Downloaded syn v3.0.4
Downloaded syn v2.0.119
Downloaded regex-syntax v0.8.11
Downloaded icu_normalizer v2.3.0
Downloaded regex-automata v0.4.18
Downloaded libc v0.2.189
Downloaded libsqlite3-sys v0.35.0
Compiling proc-macro2 v1.0.107
Compiling unicode-ident v1.0.24
Compiling quote v1.0.47
Compiling libc v0.2.189
Compiling stable_deref_trait v1.2.1
Compiling version_check v0.9.5
Compiling cfg-if v1.0.4
Compiling autocfg v1.5.1
Compiling serde_core v1.0.229
Compiling zerocopy v0.8.56
Compiling getrandom v0.3.4
Compiling serde v1.0.229
Compiling smallvec v1.15.2
Compiling memchr v2.8.3
Compiling litemap v0.8.3
Compiling num-traits v0.2.19
Compiling writeable v0.6.4
Compiling generic-array v0.14.7
Compiling icu_normalizer_data v2.3.0
Compiling utf8_iter v1.0.4
Compiling icu_properties_data v2.3.0
Compiling syn v3.0.4
Compiling syn v2.0.119
Compiling num-integer v0.1.47
Compiling typenum v1.20.1
Compiling ref-cast v1.0.27
Compiling zmij v1.0.23
Compiling parking_lot_core v0.9.12
Compiling synstructure v0.13.2
Compiling num-bigint v0.4.8
Compiling zerofrom-derive v0.1.7
Compiling yoke-derive v0.8.2
Compiling zerofrom v0.1.8
Compiling zerovec-derive v0.11.6
Compiling displaydoc v0.2.7
Compiling serde_derive v1.0.229
Compiling ref-cast-impl v1.0.27
Compiling aho-corasick v1.1.5
Compiling ahash v0.8.12
Compiling shlex v2.0.1
Compiling regex-syntax v0.8.11
Compiling find-msvc-tools v0.1.11
Compiling scopeguard v1.2.0
Compiling serde_json v1.0.151
Compiling cc v1.4.4
Compiling lock_api v0.4.14
Compiling num-rational v0.4.2
Compiling yoke v0.8.3
Compiling rand_core v0.9.5
Compiling ppv-lite86 v0.2.21
Compiling num-iter v0.1.46
Compiling num-complex v0.4.6
Compiling pkg-config v0.3.34
Compiling vcpkg v0.2.15
Compiling borrow-or-share v0.2.4
Compiling itoa v1.0.18
Compiling regex-automata v0.4.18
Compiling bit-vec v0.8.0
Compiling once_cell v1.21.4
Compiling num v0.4.3
Compiling bit-set v0.8.0
Compiling rand_chacha v0.9.0
Compiling parking_lot v0.12.5
Compiling block-buffer v0.10.4
Compiling crypto-common v0.1.7
Compiling foldhash v0.1.5
Compiling outref v0.5.2
Compiling libsqlite3-sys v0.35.0
Compiling lazy_static v1.5.0
Compiling uuid v1.26.0
Compiling percent-encoding v2.3.2
Compiling thiserror v2.0.20
Compiling vsimd v0.8.0
Compiling utf8parse v0.2.2
Compiling zerovec v0.11.8
Compiling zerotrie v0.2.5
Compiling anstyle-parse v1.0.0
Compiling uuid-simd v0.8.0
Compiling fraction v0.15.4
Compiling hashbrown v0.15.5
Compiling fluent-uri v0.3.2
Compiling email_address v0.2.9
Compiling digest v0.10.7
Compiling rand v0.9.5
Compiling thiserror-impl v2.0.20
Compiling cpufeatures v0.2.17
Compiling is_terminal_polyfill v1.70.2
Compiling num-cmp v0.1.0
Compiling referencing v0.33.0
Compiling anstyle v1.0.14
Compiling base64 v0.22.1
Compiling colorchoice v1.0.5
Compiling tinystr v0.8.4
Compiling potential_utf v0.1.6
Compiling anstyle-query v1.1.5
Compiling bytecount v0.6.9
Compiling anstream v1.0.0
Compiling ulid v1.2.1
Compiling icu_collections v2.3.0
Compiling icu_locale_core v2.3.0
Compiling regex v1.13.1
Compiling fancy-regex v0.16.2
Compiling sha2 v0.10.9
Compiling hashlink v0.10.0
Compiling heck v0.5.0
Compiling anyhow v1.0.104
Compiling clap_lex v1.1.0
Compiling bitflags v2.13.1
Compiling strsim v0.11.1
Compiling fallible-streaming-iterator v0.1.9
Compiling fallible-iterator v0.3.0
Compiling clap_derive v4.6.4
Compiling clap_builder v4.6.6
Compiling wait-timeout v0.2.1
Compiling icu_provider v2.3.1
Compiling icu_properties v2.3.0
Compiling icu_normalizer v2.3.0
Compiling idna_adapter v1.2.2
Compiling idna v1.1.0
Compiling jsonschema v0.33.0
Compiling clap v4.6.6
Compiling rusqlite v0.37.0
Compiling relayflowd-core v0.1.0 (/Users/khaliqgant/AgentWorkforce/flows-runtime-0907-wt/kernel/relayflowd-core)
Compiling relayflowd-journal v0.1.0 (/Users/khaliqgant/AgentWorkforce/flows-runtime-0907-wt/kernel/relayflowd-journal)
Compiling relayflowd v0.1.0 (/Users/khaliqgant/AgentWorkforce/flows-runtime-0907-wt/kernel/relayflowd)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 16.52s
4 changes: 4 additions & 0 deletions ops/runtime-evidence/build-sdk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

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

Loading
Loading