osuite 2.11.1 → 2.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osuite",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "description": "OSuite governed action SDK for AI agents. Approve, replay, prove, and verify runtime decisions.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -22,6 +22,9 @@
22
22
  },
23
23
  "./governed-tools": {
24
24
  "import": "./governed-tools.mjs"
25
+ },
26
+ "./controlled-transfers": {
27
+ "import": "./controlled-transfers.mjs"
25
28
  }
26
29
  },
27
30
  "files": [
@@ -36,6 +39,11 @@
36
39
  "governed-tools/*.mjs",
37
40
  "governed-tools/examples/*.mjs",
38
41
  "GOVERNED_TOOLS.md",
42
+ "controlled-transfers.mjs",
43
+ "controlled-transfers-stdio.mjs",
44
+ "controlled-transfers/*.mjs",
45
+ "CONTROLLED_TRANSFERS.md",
46
+ "matoiDoctor.mjs",
39
47
  "projectHooks.js",
40
48
  "reviewSurface.js",
41
49
  "osuite.js",
package/runtime/state.mjs CHANGED
@@ -5,16 +5,23 @@ import { randomUUID } from 'node:crypto';
5
5
  import { canonicalJson, sha256 } from './protocol.mjs';
6
6
 
7
7
  const MAX_STATE_BYTES = 2 * 1024 * 1024;
8
+ const MAX_STATE_CHECKS = 3;
8
9
 
9
10
  function checkedFile(filename) {
10
- try {
11
- const stat = fs.lstatSync(filename);
12
- if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1) throw new Error('Unsafe runtime state file');
13
- return stat;
14
- } catch (error) {
15
- if (error.code === 'ENOENT') return null;
16
- throw error;
11
+ for (let attempt = 0; attempt < MAX_STATE_CHECKS; attempt++) {
12
+ try {
13
+ const stat = fs.lstatSync(filename);
14
+ if (!stat.isFile() || stat.isSymbolicLink()) throw new Error('Unsafe runtime state file');
15
+ // Atomic replacement can detach the inode during inspection; check the new path, never trust the old one.
16
+ if (stat.nlink === 0) continue;
17
+ if (stat.nlink !== 1) throw new Error('Unsafe runtime state file');
18
+ return stat;
19
+ } catch (error) {
20
+ if (error.code === 'ENOENT') return null;
21
+ throw error;
22
+ }
17
23
  }
24
+ throw new Error('Runtime state changed during inspection');
18
25
  }
19
26
 
20
27
  export function createStateStore(config) {
@@ -34,13 +41,18 @@ export function createStateStore(config) {
34
41
  path: filename,
35
42
  read(name) {
36
43
  const file = filename(name);
37
- if (!checkedFile(file)) return null;
38
- const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0) | fs.constants.O_NONBLOCK);
39
- try {
40
- const stat = fs.fstatSync(fd);
41
- if (!stat.isFile() || stat.nlink !== 1 || stat.size > MAX_STATE_BYTES) throw new Error('Invalid runtime state file');
42
- return JSON.parse(fs.readFileSync(fd, 'utf8'));
43
- } finally { fs.closeSync(fd); }
44
+ for (let attempt = 0; attempt < MAX_STATE_CHECKS; attempt++) {
45
+ if (!checkedFile(file)) return null;
46
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0) | fs.constants.O_NONBLOCK);
47
+ try {
48
+ const stat = fs.fstatSync(fd);
49
+ if (!stat.isFile()) throw new Error('Invalid runtime state file');
50
+ if (stat.nlink === 0) continue;
51
+ if (stat.nlink !== 1 || stat.size > MAX_STATE_BYTES) throw new Error('Invalid runtime state file');
52
+ return JSON.parse(fs.readFileSync(fd, 'utf8'));
53
+ } finally { fs.closeSync(fd); }
54
+ }
55
+ throw new Error('Runtime state changed during read');
44
56
  },
45
57
  write(name, value) {
46
58
  const file = filename(name);