@unrdf/hooks 26.4.8 ā 26.5.5
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/README.md +1 -1
- package/examples/hook-chains/node_modules/.bin/jiti +2 -2
- package/examples/hook-chains/node_modules/.bin/msw +4 -4
- package/examples/hook-chains/node_modules/.bin/terser +2 -2
- package/examples/hook-chains/node_modules/.bin/tsc +2 -2
- package/examples/hook-chains/node_modules/.bin/tsserver +2 -2
- package/examples/hook-chains/node_modules/.bin/tsx +2 -2
- package/examples/hook-chains/node_modules/.bin/validate-hooks +2 -2
- package/examples/hook-chains/node_modules/.bin/vite +4 -4
- package/examples/hook-chains/node_modules/.bin/vitest +2 -2
- package/examples/hook-chains/node_modules/.bin/yaml +4 -4
- package/examples/hook-chains/package.json +3 -3
- package/examples/hooks-marketplace.mjs +10 -10
- package/examples/knowledge-hook-manager-usage.mjs +1 -1
- package/examples/policy-hooks/node_modules/.bin/jiti +2 -2
- package/examples/policy-hooks/node_modules/.bin/msw +4 -4
- package/examples/policy-hooks/node_modules/.bin/terser +2 -2
- package/examples/policy-hooks/node_modules/.bin/tsc +2 -2
- package/examples/policy-hooks/node_modules/.bin/tsserver +2 -2
- package/examples/policy-hooks/node_modules/.bin/tsx +2 -2
- package/examples/policy-hooks/node_modules/.bin/validate-hooks +2 -2
- package/examples/policy-hooks/node_modules/.bin/vite +4 -4
- package/examples/policy-hooks/node_modules/.bin/vitest +2 -2
- package/examples/policy-hooks/node_modules/.bin/yaml +4 -4
- package/examples/policy-hooks/package.json +3 -3
- package/examples/production-policy-chain.mjs +54 -0
- package/examples/semantic-inference-hook.mjs +66 -0
- package/examples/validate-hooks.mjs +1 -1
- package/package.json +10 -5
- package/src/define.mjs +3 -0
- package/src/hooks/condition-evaluator.mjs +2 -0
- package/src/hooks/dependency-graph.mjs +388 -0
- package/src/hooks/observability.mjs +67 -74
- package/src/hooks/parallel-executor.mjs +295 -0
- package/src/hooks/policy-pack.mjs +2 -2
- package/src/hooks/schemas.mjs +1 -0
- package/src/hooks/wasm4pm-conformance-bridge.mjs +25 -0
- package/src/hooks/worker-pool.mjs +478 -0
- package/examples/hook-chains/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/examples/hook-chains/unrdf-hooks-example-chains-5.0.0.tgz +0 -0
- package/examples/policy-hooks/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/examples/policy-hooks/unrdf-hooks-example-policy-5.0.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @unrdf/hooks - Knowledge Hook Engine
|
|
2
2
|
|
|
3
|
-
 
|
|
4
4
|
|
|
5
5
|
> Production-grade policy definition and execution framework for RDF knowledge graphs
|
|
6
6
|
>
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/msw@2.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/msw@2.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/msw@2.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/cli/index.js" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/msw@2.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/cli/index.js" "$@"
|
|
21
21
|
fi
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/terser@5.46.1/node_modules/terser/bin/terser" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/tsc" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/tsserver" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/dist/cli.mjs" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../@unrdf/hooks/examples/validate-hooks.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vite@7.3.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vite@7.3.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/bin/vite.js" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/bin/vite.js" "$@"
|
|
21
21
|
fi
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vitest@4.1.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules/vitest/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vitest@4.1.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules/vitest/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/yaml@2.8.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/yaml@2.8.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/bin.mjs" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/bin.mjs" "$@"
|
|
21
21
|
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unrdf/hooks-example-chains",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "26.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Hook Chains Example - Sequential hook execution and composition",
|
|
6
6
|
"private": true,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"test:coverage": "vitest run --coverage"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@unrdf/core": "
|
|
15
|
-
"@unrdf/hooks": "
|
|
14
|
+
"@unrdf/core": "workspace:*",
|
|
15
|
+
"@unrdf/hooks": "workspace:*",
|
|
16
16
|
"n3": "^1.26.0",
|
|
17
17
|
"zod": "^4.1.13"
|
|
18
18
|
},
|
|
@@ -67,7 +67,7 @@ async function main() {
|
|
|
67
67
|
const singleHook = createHook(
|
|
68
68
|
hookId1,
|
|
69
69
|
'Data Enrichment Hook',
|
|
70
|
-
'
|
|
70
|
+
'[VERSION]',
|
|
71
71
|
[], // No dependencies
|
|
72
72
|
);
|
|
73
73
|
|
|
@@ -119,9 +119,9 @@ async function main() {
|
|
|
119
119
|
const hookId2 = '550e8400-e29b-41d4-a716-446655440002';
|
|
120
120
|
const hookId3 = '550e8400-e29b-41d4-a716-446655440003';
|
|
121
121
|
|
|
122
|
-
const hookA = createHook(hookId1, 'Hook A (Base)', '
|
|
123
|
-
const hookB = createHook(hookId2, 'Hook B (depends on A)', '
|
|
124
|
-
const hookC = createHook(hookId3, 'Hook C (depends on B)', '
|
|
122
|
+
const hookA = createHook(hookId1, 'Hook A (Base)', '[VERSION]', []);
|
|
123
|
+
const hookB = createHook(hookId2, 'Hook B (depends on A)', '[VERSION]', [hookId1]);
|
|
124
|
+
const hookC = createHook(hookId3, 'Hook C (depends on B)', '[VERSION]', [hookId2]);
|
|
125
125
|
|
|
126
126
|
console.log('Admitting hooks AāBāC (valid chain)...\n');
|
|
127
127
|
|
|
@@ -145,8 +145,8 @@ async function main() {
|
|
|
145
145
|
const hookId4 = '550e8400-e29b-41d4-a716-446655440004';
|
|
146
146
|
const hookId5 = '550e8400-e29b-41d4-a716-446655440005';
|
|
147
147
|
|
|
148
|
-
const hookX = createHook(hookId4, 'Hook X', '
|
|
149
|
-
const hookY = createHook(hookId5, 'Hook Y', '
|
|
148
|
+
const hookX = createHook(hookId4, 'Hook X', '[VERSION]', [hookId5]);
|
|
149
|
+
const hookY = createHook(hookId5, 'Hook Y', '[VERSION]', [hookId4]);
|
|
150
150
|
|
|
151
151
|
console.log('Admitting hooks XāY (circular dependency)...\n');
|
|
152
152
|
|
|
@@ -175,9 +175,9 @@ async function main() {
|
|
|
175
175
|
const queryMarketplace = new HooksMarketplace();
|
|
176
176
|
|
|
177
177
|
const demoHooks = [
|
|
178
|
-
createHook('550e8400-e29b-41d4-a716-446655440010', 'Hook Alpha', '
|
|
179
|
-
createHook('550e8400-e29b-41d4-a716-446655440011', 'Hook Beta', '
|
|
180
|
-
createHook('550e8400-e29b-41d4-a716-446655440012', 'Hook Gamma', '
|
|
178
|
+
createHook('550e8400-e29b-41d4-a716-446655440010', 'Hook Alpha', '[VERSION]', []),
|
|
179
|
+
createHook('550e8400-e29b-41d4-a716-446655440011', 'Hook Beta', '[VERSION]', []),
|
|
180
|
+
createHook('550e8400-e29b-41d4-a716-446655440012', 'Hook Gamma', '[VERSION]', []),
|
|
181
181
|
];
|
|
182
182
|
|
|
183
183
|
demoHooks.forEach(h => queryMarketplace.admitHook(h));
|
|
@@ -220,7 +220,7 @@ async function main() {
|
|
|
220
220
|
const validHook = createHook(
|
|
221
221
|
'550e8400-e29b-41d4-a716-446655440020',
|
|
222
222
|
'Analytics Hook',
|
|
223
|
-
'
|
|
223
|
+
'[VERSION]',
|
|
224
224
|
[],
|
|
225
225
|
);
|
|
226
226
|
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/jiti@2.6.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti-cli.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/msw@2.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/msw@2.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/msw@2.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/cli/index.js" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/msw@2.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/msw@2.13.1_@types+node@25.5.2_typescript@5.9.3/node_modules/msw/cli/index.js" "$@"
|
|
21
21
|
fi
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules/terser/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/terser@5.46.1/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/terser@5.46.1/node_modules/terser/bin/terser" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/tsc" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/bin/tsserver" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/tsx@4.21.0/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/dist/cli.mjs" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../@unrdf/hooks/examples/validate-hooks.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vite@7.3.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vite@7.3.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/bin/vite.js" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/vite@7.3.2_@types+node@25.6.0_jiti@2.6.1_yaml@2.8.4/node_modules/vite/bin/vite.js" "$@"
|
|
21
21
|
fi
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vitest@4.1.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules/vitest/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/vitest@4.1.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules/vitest/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/vitest@4.1.5_@opentelemetry+api@1.9.1_@types+node@25.6.0_@vitest+coverage-v8@4.1.5_@vit_35c36bac87944b9fc6b84ce3fedfabeb/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
@@ -10,12 +10,12 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/yaml@2.8.
|
|
13
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/Users/sac/unrdf/node_modules/.pnpm/yaml@2.8.
|
|
15
|
+
export NODE_PATH="/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/yaml@2.8.4/node_modules:/Users/sac/chatmangpt/unrdf/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.
|
|
18
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/bin.mjs" "$@"
|
|
19
19
|
else
|
|
20
|
-
exec node "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.
|
|
20
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/yaml@2.8.4/node_modules/yaml/bin.mjs" "$@"
|
|
21
21
|
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unrdf/hooks-example-policy",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "26.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Policy Hooks Example - RDF data validation and access control",
|
|
6
6
|
"private": true,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"test:coverage": "vitest run --coverage"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@unrdf/core": "
|
|
15
|
-
"@unrdf/hooks": "
|
|
14
|
+
"@unrdf/core": "workspace:*",
|
|
15
|
+
"@unrdf/hooks": "workspace:*",
|
|
16
16
|
"n3": "^1.26.0",
|
|
17
17
|
"zod": "^4.1.13"
|
|
18
18
|
},
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { KnowledgeHookManager } from '../src/index.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Production Policy Chain Example
|
|
5
|
+
*
|
|
6
|
+
* Demonstrates a production-ready policy chain using Knowledge Hooks.
|
|
7
|
+
* The chain includes validation, transformation, and semantic reasoning stages.
|
|
8
|
+
*/
|
|
9
|
+
async function runProductionPolicyChain() {
|
|
10
|
+
console.log('š Initializing Production Policy Chain...');
|
|
11
|
+
|
|
12
|
+
const manager = new KnowledgeHookManager();
|
|
13
|
+
|
|
14
|
+
// 1. Validation Hook: Ensure required properties exist
|
|
15
|
+
manager.registerHook({
|
|
16
|
+
id: 'policy-validation-hook',
|
|
17
|
+
name: 'Validation Policy',
|
|
18
|
+
trigger: 'before-add',
|
|
19
|
+
validate: async (context) => {
|
|
20
|
+
console.log(`[Validation] Checking input data...`);
|
|
21
|
+
if (!context.resourceId) return { valid: false, error: 'Missing resourceId' };
|
|
22
|
+
return { valid: true };
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// 2. Semantic Hook: Evaluate semantic business rules (Vision 2030)
|
|
27
|
+
manager.registerHook({
|
|
28
|
+
id: 'policy-semantic-hook',
|
|
29
|
+
name: 'Semantic Business Rule',
|
|
30
|
+
trigger: 'before-add',
|
|
31
|
+
validate: async (context) => {
|
|
32
|
+
console.log(`[Semantic Reasoning] Evaluating business logic for ${context.resourceId}...`);
|
|
33
|
+
// Simulating a semantic reasoning pass using the Open Ontologies bridge
|
|
34
|
+
// This would normally call executeSemanticQuery
|
|
35
|
+
const passedSemanticCheck = true;
|
|
36
|
+
return { valid: passedSemanticCheck, status: 'Semantically Sound' };
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Execute the chain
|
|
41
|
+
console.log('\\nā” Executing chain...');
|
|
42
|
+
const payload = {
|
|
43
|
+
subject: { termType: 'NamedNode', value: 'http://example.org/res-402', equals: () => false },
|
|
44
|
+
predicate: { termType: 'NamedNode', value: 'http://example.org/type', equals: () => false },
|
|
45
|
+
object: { termType: 'NamedNode', value: 'http://example.org/PolicyUpdate', equals: () => false },
|
|
46
|
+
resourceId: 'res-402' // Attach custom context for the validation hook
|
|
47
|
+
};
|
|
48
|
+
const result = await manager.executeByTrigger('before-add', payload);
|
|
49
|
+
|
|
50
|
+
console.log('\\nā
Chain Execution Complete:');
|
|
51
|
+
console.log(JSON.stringify(result, null, 2));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
runProductionPolicyChain().catch(console.error);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { KnowledgeHookManager } from '../src/hooks/knowledge-hook-manager.mjs';
|
|
2
|
+
import { executeSemanticQuery, createSemanticCondition } from '@unrdf/core/utils/semantic-bridge';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
// Initialize the UNRDF Knowledge Hook Manager
|
|
6
|
+
const manager = new KnowledgeHookManager();
|
|
7
|
+
|
|
8
|
+
// Define a semantic condition:
|
|
9
|
+
// Trigger ONLY IF the Open Ontologies reasoner/query engine confirms the semantic state.
|
|
10
|
+
// In this PoC, we query the pizza.ttl ontology we created earlier.
|
|
11
|
+
const sparqlQuery = `
|
|
12
|
+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
13
|
+
PREFIX ex: <http://example.org/pizza#>
|
|
14
|
+
SELECT ?subclass WHERE {
|
|
15
|
+
?subclass rdfs:subClassOf ex:Pizza .
|
|
16
|
+
?subclass rdfs:label "Margherita" .
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const ontologyFiles = [
|
|
21
|
+
path.join(process.cwd(), 'pizza.ttl') // Path to the generated pizza.ttl
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const semanticCondition = createSemanticCondition(sparqlQuery, ontologyFiles);
|
|
25
|
+
|
|
26
|
+
// Register the Autonomous Hook
|
|
27
|
+
manager.registerHook({
|
|
28
|
+
id: 'semantic-pizza-detector',
|
|
29
|
+
name: 'Semantic Pizza Detector',
|
|
30
|
+
version: '[VERSION]',
|
|
31
|
+
trigger: 'after-add',
|
|
32
|
+
enabled: true,
|
|
33
|
+
description: 'Triggers autonomically when the Open Ontologies graph proves Margherita exists',
|
|
34
|
+
validate: async (context) => {
|
|
35
|
+
console.log('š§ Evaluating Semantic Condition via Open Ontologies...');
|
|
36
|
+
const result = await semanticCondition(context);
|
|
37
|
+
|
|
38
|
+
if (result) {
|
|
39
|
+
console.log('šØ SEMANTIC INFERENCE TRIGGERED: The graph formally proved the existence of Margherita.');
|
|
40
|
+
console.log('š¤ Executing autonomic remediation/action based on logic, not hardcoded metrics!');
|
|
41
|
+
return true;
|
|
42
|
+
} else {
|
|
43
|
+
console.log('No semantic conditions met.');
|
|
44
|
+
return true; // Return true to allow the quad through, but log that it wasn't our condition
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Simulate the system triggering an event (like a data ingest)
|
|
50
|
+
async function runDemo() {
|
|
51
|
+
console.log('--- Vision 2030: Semantic Knowledge Hooks Demo ---');
|
|
52
|
+
console.log('Triggering data:ingest event...\n');
|
|
53
|
+
|
|
54
|
+
const mockQuad = {
|
|
55
|
+
subject: { termType: 'NamedNode', value: 'http://example.org/subject', equals: () => false },
|
|
56
|
+
predicate: { termType: 'NamedNode', value: 'http://example.org/predicate', equals: () => false },
|
|
57
|
+
object: { termType: 'Literal', value: 'event-triggered', equals: () => false }
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const results = await manager.executeByTrigger('after-add', mockQuad);
|
|
61
|
+
|
|
62
|
+
console.log('\n--- Hook Execution Results ---');
|
|
63
|
+
console.log(JSON.stringify(results, null, 2));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
runDemo().catch(console.error);
|