diff --git a/plugins/reporting-governance/src/adapters/index.mjs b/plugins/reporting-governance/src/adapters/index.mjs index d8d526a..b9cf8af 100644 --- a/plugins/reporting-governance/src/adapters/index.mjs +++ b/plugins/reporting-governance/src/adapters/index.mjs @@ -1,6 +1,7 @@ -export { createRuntimeBinding, resolveScriptPath, SCRIPT_ENV_KEYS, SCRIPT_NAMES } from './runtime-binding.mjs'; export { runWatchdogAdapter } from './watchdog.mjs'; export { runDispatcherAdapter } from './dispatcher.mjs'; export { runBridgeSupervisorAdapter } from './bridge-supervisor.mjs'; export { runSenderBindingAdapter } from './sender-binding.mjs'; export { runOrchestratorAdapter } from './orchestrator.mjs'; + +export { createRuntimeBinding } from './runtime-binding.mjs'; diff --git a/plugins/reporting-governance/src/index.mjs b/plugins/reporting-governance/src/index.mjs index 6259473..25b36ee 100644 --- a/plugins/reporting-governance/src/index.mjs +++ b/plugins/reporting-governance/src/index.mjs @@ -32,9 +32,6 @@ export const packageBoundaries = { export { evaluatePolicyPack, evaluatePolicies, planDecisionExecution } from './core/index.mjs'; export { createRuntimeBinding, - resolveScriptPath, - SCRIPT_ENV_KEYS, - SCRIPT_NAMES, runWatchdogAdapter, runDispatcherAdapter, runBridgeSupervisorAdapter, diff --git a/plugins/reporting-governance/test/exports-boundary.integration.test.mjs b/plugins/reporting-governance/test/exports-boundary.integration.test.mjs index d6c323d..f694d0f 100644 --- a/plugins/reporting-governance/test/exports-boundary.integration.test.mjs +++ b/plugins/reporting-governance/test/exports-boundary.integration.test.mjs @@ -40,7 +40,7 @@ function writeState(root) { } function runNodeEval(root, source, env = {}) { - const result = spawnSync(process.execPath, ['--input-type=module', '--eval', source], { + return spawnSync(process.execPath, ['--input-type=module', '--eval', source], { cwd: root, encoding: 'utf8', env: { @@ -48,6 +48,10 @@ function runNodeEval(root, source, env = {}) { ...env, }, }); +} + +function runJsonEval(root, source, env = {}) { + const result = runNodeEval(root, source, env); if (result.status !== 0) { throw new Error(`node eval failed: ${(result.stderr ?? '').trim() || '(no stderr)'}`); } @@ -58,7 +62,7 @@ test('package root export resolves public package surface only', () => { const root = createFixtureRoot(); try { installPackageAlias(root); - const result = runNodeEval(root, ` + const result = runJsonEval(root, ` import * as plugin from '@openclaw/plugin-reporting-governance'; process.stdout.write(JSON.stringify({ packageName: plugin.packageName, @@ -79,7 +83,7 @@ test('adapters subpath export resolves package-owned adapter index', () => { const root = createFixtureRoot(); try { installPackageAlias(root); - const result = runNodeEval(root, ` + const result = runJsonEval(root, ` import * as adapters from '@openclaw/plugin-reporting-governance/adapters'; process.stdout.write(JSON.stringify({ adapterKeys: Object.keys(adapters).sort(), @@ -87,10 +91,7 @@ test('adapters subpath export resolves package-owned adapter index', () => { `); assert.deepEqual(result.adapterKeys, [ - 'SCRIPT_ENV_KEYS', - 'SCRIPT_NAMES', 'createRuntimeBinding', - 'resolveScriptPath', 'runBridgeSupervisorAdapter', 'runDispatcherAdapter', 'runOrchestratorAdapter', @@ -102,6 +103,36 @@ test('adapters subpath export resolves package-owned adapter index', () => { } }); +test('deep runtime-binding subpath stays outside package exports boundary', () => { + const root = createFixtureRoot(); + try { + installPackageAlias(root); + const result = runNodeEval(root, ` + import('@openclaw/plugin-reporting-governance/src/adapters/runtime-binding.mjs') + .then(() => { + process.stdout.write(JSON.stringify({ ok: true })); + }) + .catch((error) => { + process.stdout.write(JSON.stringify({ + ok: false, + code: error?.code ?? null, + name: error?.name ?? null, + message: error?.message ?? null, + })); + }); + `); + + assert.equal(result.status, 0, result.stderr); + const payload = JSON.parse((result.stdout ?? '').trim()); + assert.equal(payload.ok, false); + assert.equal(payload.code, 'ERR_PACKAGE_PATH_NOT_EXPORTED'); + assert.equal(payload.name, 'Error'); + assert.match(payload.message ?? '', /Package subpath '\.\/src\/adapters\/runtime-binding\.mjs' is not defined by "exports"/); + } finally { + fs.rmSync(root, { recursive: true, force: true }); + } +}); + test('leaf subpath export resolves and can execute through injected runtime binding', () => { const root = createFixtureRoot(); try { @@ -121,7 +152,7 @@ test('leaf subpath export resolves and can execute through injected runtime bind })); `, 'utf8'); - const result = runNodeEval(root, ` + const result = runJsonEval(root, ` import { runWatchdogAdapter } from '@openclaw/plugin-reporting-governance/adapters/watchdog'; const out = runWatchdogAdapter({ state: ${JSON.stringify(statePath)},