@a5c-ai/agent-platform 5.0.1-staging.b436b3b3e611
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 +53 -0
- package/dist/anycli/cache.d.ts +45 -0
- package/dist/anycli/cache.d.ts.map +1 -0
- package/dist/anycli/cache.js +118 -0
- package/dist/anycli/index.d.ts +10 -0
- package/dist/anycli/index.d.ts.map +1 -0
- package/dist/anycli/index.js +25 -0
- package/dist/anycli/types.d.ts +32 -0
- package/dist/anycli/types.d.ts.map +1 -0
- package/dist/anycli/types.js +9 -0
- package/dist/api/breakpoints.d.ts +93 -0
- package/dist/api/breakpoints.d.ts.map +1 -0
- package/dist/api/breakpoints.js +334 -0
- package/dist/api/effects.d.ts +14 -0
- package/dist/api/effects.d.ts.map +1 -0
- package/dist/api/effects.js +306 -0
- package/dist/api/effectsTypes.d.ts +79 -0
- package/dist/api/effectsTypes.d.ts.map +1 -0
- package/dist/api/effectsTypes.js +6 -0
- package/dist/api/eventStream.d.ts +34 -0
- package/dist/api/eventStream.d.ts.map +1 -0
- package/dist/api/eventStream.js +126 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +27 -0
- package/dist/api/runs.d.ts +85 -0
- package/dist/api/runs.d.ts.map +1 -0
- package/dist/api/runs.js +247 -0
- package/dist/api/utils.d.ts +28 -0
- package/dist/api/utils.d.ts.map +1 -0
- package/dist/api/utils.js +74 -0
- package/dist/breakpoints/approvalChains.d.ts +68 -0
- package/dist/breakpoints/approvalChains.d.ts.map +1 -0
- package/dist/breakpoints/approvalChains.js +111 -0
- package/dist/breakpoints/delegation.d.ts +42 -0
- package/dist/breakpoints/delegation.d.ts.map +1 -0
- package/dist/breakpoints/delegation.js +199 -0
- package/dist/breakpoints/delegationTypes.d.ts +46 -0
- package/dist/breakpoints/delegationTypes.d.ts.map +1 -0
- package/dist/breakpoints/delegationTypes.js +10 -0
- package/dist/breakpoints/postures.d.ts +28 -0
- package/dist/breakpoints/postures.d.ts.map +1 -0
- package/dist/breakpoints/postures.js +100 -0
- package/dist/cli/amuxEventsFormatter.d.ts +26 -0
- package/dist/cli/amuxEventsFormatter.d.ts.map +1 -0
- package/dist/cli/amuxEventsFormatter.js +86 -0
- package/dist/cli/args/argFlags.d.ts +6 -0
- package/dist/cli/args/argFlags.d.ts.map +1 -0
- package/dist/cli/args/argFlags.js +72 -0
- package/dist/cli/args/argPositionals.d.ts +3 -0
- package/dist/cli/args/argPositionals.d.ts.map +1 -0
- package/dist/cli/args/argPositionals.js +18 -0
- package/dist/cli/args/index.d.ts +4 -0
- package/dist/cli/args/index.d.ts.map +1 -0
- package/dist/cli/args/index.js +75 -0
- package/dist/cli/args/types.d.ts +13 -0
- package/dist/cli/args/types.d.ts.map +1 -0
- package/dist/cli/args/types.js +2 -0
- package/dist/cli/commands/daemon.d.ts +31 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +156 -0
- package/dist/cli/commands/harness/createRun.d.ts +3 -0
- package/dist/cli/commands/harness/createRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/createRun.js +8 -0
- package/dist/cli/commands/harness/resumeRun.d.ts +20 -0
- package/dist/cli/commands/harness/resumeRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/resumeRun.js +341 -0
- package/dist/cli/commands/jsonlInteractive.d.ts +35 -0
- package/dist/cli/commands/jsonlInteractive.d.ts.map +1 -0
- package/dist/cli/commands/jsonlInteractive.js +302 -0
- package/dist/cli/commands/mcpServe.d.ts +18 -0
- package/dist/cli/commands/mcpServe.d.ts.map +1 -0
- package/dist/cli/commands/mcpServe.js +59 -0
- package/dist/cli/commands/session/history.d.ts +14 -0
- package/dist/cli/commands/session/history.d.ts.map +1 -0
- package/dist/cli/commands/session/history.js +100 -0
- package/dist/cli/commands/tui.d.ts +23 -0
- package/dist/cli/commands/tui.d.ts.map +1 -0
- package/dist/cli/commands/tui.js +183 -0
- package/dist/cli/dispatch.d.ts +4 -0
- package/dist/cli/dispatch.d.ts.map +1 -0
- package/dist/cli/dispatch.js +332 -0
- package/dist/cli/main.d.ts +7 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +41 -0
- package/dist/cli/program.d.ts +7 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +8 -0
- package/dist/cli/ui.d.ts +9 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/ui.js +125 -0
- package/dist/compression/compaction.d.ts +82 -0
- package/dist/compression/compaction.d.ts.map +1 -0
- package/dist/compression/compaction.js +310 -0
- package/dist/cost/claudeCodeParser.d.ts +81 -0
- package/dist/cost/claudeCodeParser.d.ts.map +1 -0
- package/dist/cost/claudeCodeParser.js +232 -0
- package/dist/cost/collector.d.ts +42 -0
- package/dist/cost/collector.d.ts.map +1 -0
- package/dist/cost/collector.js +105 -0
- package/dist/cost/effectCost.d.ts +23 -0
- package/dist/cost/effectCost.d.ts.map +1 -0
- package/dist/cost/effectCost.js +26 -0
- package/dist/cost/index.d.ts +7 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +28 -0
- package/dist/cost/journal.d.ts +40 -0
- package/dist/cost/journal.d.ts.map +1 -0
- package/dist/cost/journal.js +137 -0
- package/dist/cost/types.d.ts +164 -0
- package/dist/cost/types.d.ts.map +1 -0
- package/dist/cost/types.js +228 -0
- package/dist/daemon/automationExecutor.d.ts +16 -0
- package/dist/daemon/automationExecutor.d.ts.map +1 -0
- package/dist/daemon/automationExecutor.js +222 -0
- package/dist/daemon/config.d.ts +8 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +209 -0
- package/dist/daemon/daemonLog.d.ts +13 -0
- package/dist/daemon/daemonLog.d.ts.map +1 -0
- package/dist/daemon/daemonLog.js +64 -0
- package/dist/daemon/fileWatcher.d.ts +9 -0
- package/dist/daemon/fileWatcher.d.ts.map +1 -0
- package/dist/daemon/fileWatcher.js +141 -0
- package/dist/daemon/index.d.ts +7 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +21 -0
- package/dist/daemon/lifecycle.d.ts +12 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +257 -0
- package/dist/daemon/loop.d.ts +21 -0
- package/dist/daemon/loop.d.ts.map +1 -0
- package/dist/daemon/loop.js +196 -0
- package/dist/daemon/timerScheduler.d.ts +13 -0
- package/dist/daemon/timerScheduler.d.ts.map +1 -0
- package/dist/daemon/timerScheduler.js +122 -0
- package/dist/daemon/types.d.ts +93 -0
- package/dist/daemon/types.d.ts.map +1 -0
- package/dist/daemon/types.js +25 -0
- package/dist/daemon/webhookListener.d.ts +6 -0
- package/dist/daemon/webhookListener.d.ts.map +1 -0
- package/dist/daemon/webhookListener.js +110 -0
- package/dist/governance/authority.d.ts +68 -0
- package/dist/governance/authority.d.ts.map +1 -0
- package/dist/governance/authority.js +136 -0
- package/dist/governance/bridge.d.ts +17 -0
- package/dist/governance/bridge.d.ts.map +1 -0
- package/dist/governance/bridge.js +46 -0
- package/dist/governance/builtins.d.ts +25 -0
- package/dist/governance/builtins.d.ts.map +1 -0
- package/dist/governance/builtins.js +67 -0
- package/dist/governance/categories.d.ts +58 -0
- package/dist/governance/categories.d.ts.map +1 -0
- package/dist/governance/categories.js +120 -0
- package/dist/governance/decisionTrail.d.ts +60 -0
- package/dist/governance/decisionTrail.d.ts.map +1 -0
- package/dist/governance/decisionTrail.js +68 -0
- package/dist/governance/engine.d.ts +20 -0
- package/dist/governance/engine.d.ts.map +1 -0
- package/dist/governance/engine.js +124 -0
- package/dist/governance/index.d.ts +20 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/index.js +75 -0
- package/dist/governance/logging.d.ts +18 -0
- package/dist/governance/logging.d.ts.map +1 -0
- package/dist/governance/logging.js +83 -0
- package/dist/governance/mandate.d.ts +83 -0
- package/dist/governance/mandate.d.ts.map +1 -0
- package/dist/governance/mandate.js +180 -0
- package/dist/governance/permissionEvents.d.ts +51 -0
- package/dist/governance/permissionEvents.d.ts.map +1 -0
- package/dist/governance/permissionEvents.js +52 -0
- package/dist/governance/permissionPropagation.d.ts +18 -0
- package/dist/governance/permissionPropagation.d.ts.map +1 -0
- package/dist/governance/permissionPropagation.js +58 -0
- package/dist/governance/postureBridge.d.ts +17 -0
- package/dist/governance/postureBridge.d.ts.map +1 -0
- package/dist/governance/postureBridge.js +117 -0
- package/dist/governance/sandboxBridge.d.ts +49 -0
- package/dist/governance/sandboxBridge.d.ts.map +1 -0
- package/dist/governance/sandboxBridge.js +77 -0
- package/dist/governance/sandboxPolicy.d.ts +51 -0
- package/dist/governance/sandboxPolicy.d.ts.map +1 -0
- package/dist/governance/sandboxPolicy.js +177 -0
- package/dist/governance/types.d.ts +3 -0
- package/dist/governance/types.d.ts.map +1 -0
- package/dist/governance/types.js +5 -0
- package/dist/harness/amux/amuxBridge.d.ts +71 -0
- package/dist/harness/amux/amuxBridge.d.ts.map +1 -0
- package/dist/harness/amux/amuxBridge.js +117 -0
- package/dist/harness/amux/amuxClientFactory.d.ts +29 -0
- package/dist/harness/amux/amuxClientFactory.d.ts.map +1 -0
- package/dist/harness/amux/amuxClientFactory.js +90 -0
- package/dist/harness/amux/amuxEventEmitter.d.ts +51 -0
- package/dist/harness/amux/amuxEventEmitter.d.ts.map +1 -0
- package/dist/harness/amux/amuxEventEmitter.js +143 -0
- package/dist/harness/amux/amuxEventMapper.d.ts +58 -0
- package/dist/harness/amux/amuxEventMapper.d.ts.map +1 -0
- package/dist/harness/amux/amuxEventMapper.js +92 -0
- package/dist/harness/amux/amuxHarnessMap.d.ts +25 -0
- package/dist/harness/amux/amuxHarnessMap.d.ts.map +1 -0
- package/dist/harness/amux/amuxHarnessMap.js +55 -0
- package/dist/harness/amux/amuxStdinReader.d.ts +45 -0
- package/dist/harness/amux/amuxStdinReader.d.ts.map +1 -0
- package/dist/harness/amux/amuxStdinReader.js +106 -0
- package/dist/harness/amux/amuxTypes.d.ts +122 -0
- package/dist/harness/amux/amuxTypes.d.ts.map +1 -0
- package/dist/harness/amux/amuxTypes.js +11 -0
- package/dist/harness/amux/index.d.ts +17 -0
- package/dist/harness/amux/index.d.ts.map +1 -0
- package/dist/harness/amux/index.js +34 -0
- package/dist/harness/backgroundTracker.d.ts +64 -0
- package/dist/harness/backgroundTracker.d.ts.map +1 -0
- package/dist/harness/backgroundTracker.js +107 -0
- package/dist/harness/builtInHarness.d.ts +3 -0
- package/dist/harness/builtInHarness.d.ts.map +1 -0
- package/dist/harness/builtInHarness.js +18 -0
- package/dist/harness/capabilityRouter.d.ts +76 -0
- package/dist/harness/capabilityRouter.d.ts.map +1 -0
- package/dist/harness/capabilityRouter.js +176 -0
- package/dist/harness/fallbackChains.d.ts +42 -0
- package/dist/harness/fallbackChains.d.ts.map +1 -0
- package/dist/harness/fallbackChains.js +69 -0
- package/dist/harness/hostContract.d.ts +63 -0
- package/dist/harness/hostContract.d.ts.map +1 -0
- package/dist/harness/hostContract.js +136 -0
- package/dist/harness/index.d.ts +10 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +66 -0
- package/dist/harness/internal/createRun/askUserQuestion.d.ts +11 -0
- package/dist/harness/internal/createRun/askUserQuestion.d.ts.map +1 -0
- package/dist/harness/internal/createRun/askUserQuestion.js +162 -0
- package/dist/harness/internal/createRun/index.d.ts +25 -0
- package/dist/harness/internal/createRun/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/index.js +137 -0
- package/dist/harness/internal/createRun/orchestration/constants.d.ts +7 -0
- package/dist/harness/internal/createRun/orchestration/constants.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/constants.js +13 -0
- package/dist/harness/internal/createRun/orchestration/effects.d.ts +43 -0
- package/dist/harness/internal/createRun/orchestration/effects.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/effects.js +490 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.d.ts +20 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.js +79 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.d.ts +3 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.js +319 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.d.ts +16 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.js +104 -0
- package/dist/harness/internal/createRun/orchestration/index.d.ts +14 -0
- package/dist/harness/internal/createRun/orchestration/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/index.js +36 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.d.ts +3 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.js +464 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.d.ts +26 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.js +262 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.d.ts +17 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.js +23 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.d.ts +10 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.js +67 -0
- package/dist/harness/internal/createRun/orchestration/types.d.ts +46 -0
- package/dist/harness/internal/createRun/orchestration/types.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/types.js +2 -0
- package/dist/harness/internal/createRun/orchestration/verbose.d.ts +7 -0
- package/dist/harness/internal/createRun/orchestration/verbose.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/verbose.js +240 -0
- package/dist/harness/internal/createRun/output.d.ts +38 -0
- package/dist/harness/internal/createRun/output.d.ts.map +1 -0
- package/dist/harness/internal/createRun/output.js +415 -0
- package/dist/harness/internal/createRun/pi.d.ts +34 -0
- package/dist/harness/internal/createRun/pi.d.ts.map +1 -0
- package/dist/harness/internal/createRun/pi.js +216 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.d.ts +5 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.js +113 -0
- package/dist/harness/internal/createRun/planProcess/delegation.d.ts +23 -0
- package/dist/harness/internal/createRun/planProcess/delegation.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/delegation.js +176 -0
- package/dist/harness/internal/createRun/planProcess/external.d.ts +14 -0
- package/dist/harness/internal/createRun/planProcess/external.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/external.js +139 -0
- package/dist/harness/internal/createRun/planProcess/index.d.ts +12 -0
- package/dist/harness/internal/createRun/planProcess/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/index.js +24 -0
- package/dist/harness/internal/createRun/planProcess/paths.d.ts +7 -0
- package/dist/harness/internal/createRun/planProcess/paths.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/paths.js +98 -0
- package/dist/harness/internal/createRun/planProcess/phase.d.ts +6 -0
- package/dist/harness/internal/createRun/planProcess/phase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phase.js +361 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.d.ts +37 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.js +159 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.d.ts +25 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.js +6 -0
- package/dist/harness/internal/createRun/planProcess/prompts.d.ts +20 -0
- package/dist/harness/internal/createRun/planProcess/prompts.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/prompts.js +208 -0
- package/dist/harness/internal/createRun/planProcess/recovery.d.ts +18 -0
- package/dist/harness/internal/createRun/planProcess/recovery.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/recovery.js +188 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.d.ts +2 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.js +68 -0
- package/dist/harness/internal/createRun/planProcess/runState.d.ts +40 -0
- package/dist/harness/internal/createRun/planProcess/runState.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/runState.js +179 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.d.ts +22 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.js +65 -0
- package/dist/harness/internal/createRun/planProcess/validation.d.ts +2 -0
- package/dist/harness/internal/createRun/planProcess/validation.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validation.js +212 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.d.ts +11 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.js +328 -0
- package/dist/harness/internal/createRun/planProcess/validationText.d.ts +3 -0
- package/dist/harness/internal/createRun/planProcess/validationText.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validationText.js +145 -0
- package/dist/harness/internal/createRun/prompts.d.ts +49 -0
- package/dist/harness/internal/createRun/prompts.d.ts.map +1 -0
- package/dist/harness/internal/createRun/prompts.js +307 -0
- package/dist/harness/internal/createRun/resumeState.d.ts +28 -0
- package/dist/harness/internal/createRun/resumeState.d.ts.map +1 -0
- package/dist/harness/internal/createRun/resumeState.js +133 -0
- package/dist/harness/internal/createRun/utils.d.ts +182 -0
- package/dist/harness/internal/createRun/utils.d.ts.map +1 -0
- package/dist/harness/internal/createRun/utils.js +133 -0
- package/dist/harness/internal.d.ts +13 -0
- package/dist/harness/internal.d.ts.map +1 -0
- package/dist/harness/internal.js +149 -0
- package/dist/harness/invoker/launch.d.ts +20 -0
- package/dist/harness/invoker/launch.d.ts.map +1 -0
- package/dist/harness/invoker/launch.js +23 -0
- package/dist/harness/invoker/processControl.d.ts +11 -0
- package/dist/harness/invoker/processControl.d.ts.map +1 -0
- package/dist/harness/invoker/processControl.js +50 -0
- package/dist/harness/invoker.d.ts +43 -0
- package/dist/harness/invoker.d.ts.map +1 -0
- package/dist/harness/invoker.js +210 -0
- package/dist/harness/modeSelector.d.ts +50 -0
- package/dist/harness/modeSelector.d.ts.map +1 -0
- package/dist/harness/modeSelector.js +124 -0
- package/dist/harness/modelSelection.d.ts +37 -0
- package/dist/harness/modelSelection.d.ts.map +1 -0
- package/dist/harness/modelSelection.js +81 -0
- package/dist/harness/operatorCommands.d.ts +38 -0
- package/dist/harness/operatorCommands.d.ts.map +1 -0
- package/dist/harness/operatorCommands.js +118 -0
- package/dist/harness/piSecureSandbox.d.ts +8 -0
- package/dist/harness/piSecureSandbox.d.ts.map +1 -0
- package/dist/harness/piSecureSandbox.js +366 -0
- package/dist/harness/piSecureSandboxTypes.d.ts +51 -0
- package/dist/harness/piSecureSandboxTypes.d.ts.map +1 -0
- package/dist/harness/piSecureSandboxTypes.js +6 -0
- package/dist/harness/piWrapper/compaction.d.ts +13 -0
- package/dist/harness/piWrapper/compaction.d.ts.map +1 -0
- package/dist/harness/piWrapper/compaction.js +38 -0
- package/dist/harness/piWrapper/instructionPrompts.d.ts +2 -0
- package/dist/harness/piWrapper/instructionPrompts.d.ts.map +1 -0
- package/dist/harness/piWrapper/instructionPrompts.js +97 -0
- package/dist/harness/piWrapper/moduleSupport.d.ts +77 -0
- package/dist/harness/piWrapper/moduleSupport.d.ts.map +1 -0
- package/dist/harness/piWrapper/moduleSupport.js +204 -0
- package/dist/harness/piWrapper.d.ts +80 -0
- package/dist/harness/piWrapper.d.ts.map +1 -0
- package/dist/harness/piWrapper.js +389 -0
- package/dist/harness/piWrapper.test.d.ts +2 -0
- package/dist/harness/piWrapper.test.d.ts.map +1 -0
- package/dist/harness/piWrapper.test.js +193 -0
- package/dist/harness/planMode.d.ts +68 -0
- package/dist/harness/planMode.d.ts.map +1 -0
- package/dist/harness/planMode.js +145 -0
- package/dist/harness/selectionPolicies.d.ts +29 -0
- package/dist/harness/selectionPolicies.d.ts.map +1 -0
- package/dist/harness/selectionPolicies.js +165 -0
- package/dist/harness/types.d.ts +266 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +34 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/interaction/askUserQuestion/core.d.ts +8 -0
- package/dist/interaction/askUserQuestion/core.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion/core.js +112 -0
- package/dist/interaction/askUserQuestion/terminal.d.ts +15 -0
- package/dist/interaction/askUserQuestion/terminal.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion/terminal.js +128 -0
- package/dist/interaction/askUserQuestion.d.ts +10 -0
- package/dist/interaction/askUserQuestion.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion.js +295 -0
- package/dist/interaction/askUserQuestionTypes.d.ts +31 -0
- package/dist/interaction/askUserQuestionTypes.d.ts.map +1 -0
- package/dist/interaction/askUserQuestionTypes.js +6 -0
- package/dist/interaction/index.d.ts +4 -0
- package/dist/interaction/index.d.ts.map +1 -0
- package/dist/interaction/index.js +20 -0
- package/dist/interaction/interactionRouter.d.ts +25 -0
- package/dist/interaction/interactionRouter.d.ts.map +1 -0
- package/dist/interaction/interactionRouter.js +55 -0
- package/dist/mcp/channels/allowlist.d.ts +19 -0
- package/dist/mcp/channels/allowlist.d.ts.map +1 -0
- package/dist/mcp/channels/allowlist.js +140 -0
- package/dist/mcp/channels/channelManager.d.ts +64 -0
- package/dist/mcp/channels/channelManager.d.ts.map +1 -0
- package/dist/mcp/channels/channelManager.js +137 -0
- package/dist/mcp/channels/inboundQueue.d.ts +47 -0
- package/dist/mcp/channels/inboundQueue.d.ts.map +1 -0
- package/dist/mcp/channels/inboundQueue.js +96 -0
- package/dist/mcp/channels/index.d.ts +17 -0
- package/dist/mcp/channels/index.d.ts.map +1 -0
- package/dist/mcp/channels/index.js +39 -0
- package/dist/mcp/channels/outbound.d.ts +33 -0
- package/dist/mcp/channels/outbound.d.ts.map +1 -0
- package/dist/mcp/channels/outbound.js +94 -0
- package/dist/mcp/channels/permissionRelay.d.ts +62 -0
- package/dist/mcp/channels/permissionRelay.d.ts.map +1 -0
- package/dist/mcp/channels/permissionRelay.js +159 -0
- package/dist/mcp/channels/types.d.ts +135 -0
- package/dist/mcp/channels/types.d.ts.map +1 -0
- package/dist/mcp/channels/types.js +16 -0
- package/dist/mcp/client/config.d.ts +28 -0
- package/dist/mcp/client/config.d.ts.map +1 -0
- package/dist/mcp/client/config.js +142 -0
- package/dist/mcp/client/executor.d.ts +30 -0
- package/dist/mcp/client/executor.d.ts.map +1 -0
- package/dist/mcp/client/executor.js +60 -0
- package/dist/mcp/client/index.d.ts +12 -0
- package/dist/mcp/client/index.d.ts.map +1 -0
- package/dist/mcp/client/index.js +27 -0
- package/dist/mcp/client/manager.d.ts +74 -0
- package/dist/mcp/client/manager.d.ts.map +1 -0
- package/dist/mcp/client/manager.js +214 -0
- package/dist/mcp/client/toolRegistry.d.ts +50 -0
- package/dist/mcp/client/toolRegistry.d.ts.map +1 -0
- package/dist/mcp/client/toolRegistry.js +118 -0
- package/dist/mcp/client/types.d.ts +96 -0
- package/dist/mcp/client/types.d.ts.map +1 -0
- package/dist/mcp/client/types.js +15 -0
- package/dist/mcp/transport/index.d.ts +9 -0
- package/dist/mcp/transport/index.d.ts.map +1 -0
- package/dist/mcp/transport/index.js +13 -0
- package/dist/mcp/transport/session.d.ts +18 -0
- package/dist/mcp/transport/session.d.ts.map +1 -0
- package/dist/mcp/transport/session.js +78 -0
- package/dist/mcp/transport/types.d.ts +19 -0
- package/dist/mcp/transport/types.d.ts.map +1 -0
- package/dist/mcp/transport/types.js +7 -0
- package/dist/mcp/transport/websocket.d.ts +41 -0
- package/dist/mcp/transport/websocket.d.ts.map +1 -0
- package/dist/mcp/transport/websocket.js +271 -0
- package/dist/observability/health.d.ts +19 -0
- package/dist/observability/health.d.ts.map +1 -0
- package/dist/observability/health.js +129 -0
- package/dist/observability/index.d.ts +7 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +22 -0
- package/dist/observability/runStatus.d.ts +44 -0
- package/dist/observability/runStatus.d.ts.map +1 -0
- package/dist/observability/runStatus.js +169 -0
- package/dist/observability/timeline.d.ts +11 -0
- package/dist/observability/timeline.d.ts.map +1 -0
- package/dist/observability/timeline.js +176 -0
- package/dist/observability/types.d.ts +62 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +8 -0
- package/dist/observability/webhooks.d.ts +68 -0
- package/dist/observability/webhooks.d.ts.map +1 -0
- package/dist/observability/webhooks.js +132 -0
- package/dist/prompts/commandTemplates.d.ts +3 -0
- package/dist/prompts/commandTemplates.d.ts.map +1 -0
- package/dist/prompts/commandTemplates.js +238 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +28 -0
- package/dist/seams/contract.d.ts +55 -0
- package/dist/seams/contract.d.ts.map +1 -0
- package/dist/seams/contract.js +120 -0
- package/dist/seams/contract.test.d.ts +2 -0
- package/dist/seams/contract.test.d.ts.map +1 -0
- package/dist/seams/contract.test.js +96 -0
- package/dist/seams/index.d.ts +3 -0
- package/dist/seams/index.d.ts.map +1 -0
- package/dist/seams/index.js +8 -0
- package/dist/session/context.d.ts +22 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +113 -0
- package/dist/session/continuityState.d.ts +39 -0
- package/dist/session/continuityState.d.ts.map +1 -0
- package/dist/session/continuityState.js +164 -0
- package/dist/session/cost.d.ts +63 -0
- package/dist/session/cost.d.ts.map +1 -0
- package/dist/session/cost.js +194 -0
- package/dist/session/discovery.d.ts +22 -0
- package/dist/session/discovery.d.ts.map +1 -0
- package/dist/session/discovery.js +35 -0
- package/dist/session/history.d.ts +30 -0
- package/dist/session/history.d.ts.map +1 -0
- package/dist/session/history.js +143 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +70 -0
- package/dist/session/memoryExtraction.d.ts +65 -0
- package/dist/session/memoryExtraction.d.ts.map +1 -0
- package/dist/session/memoryExtraction.js +201 -0
- package/dist/session/parse.d.ts +45 -0
- package/dist/session/parse.d.ts.map +1 -0
- package/dist/session/parse.js +170 -0
- package/dist/session/persistence.d.ts +46 -0
- package/dist/session/persistence.d.ts.map +1 -0
- package/dist/session/persistence.js +180 -0
- package/dist/session/types.d.ts +267 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +45 -0
- package/dist/session/write.d.ts +61 -0
- package/dist/session/write.d.ts.map +1 -0
- package/dist/session/write.js +213 -0
- package/dist/storage/atomic.d.ts +2 -0
- package/dist/storage/atomic.d.ts.map +1 -0
- package/dist/storage/atomic.js +54 -0
- package/dist/storage/clock.d.ts +2 -0
- package/dist/storage/clock.d.ts.map +1 -0
- package/dist/storage/clock.js +6 -0
- package/dist/storage/index.d.ts +7 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/journalWatcher.d.ts +24 -0
- package/dist/storage/journalWatcher.d.ts.map +1 -0
- package/dist/storage/journalWatcher.js +172 -0
- package/dist/storage/paths.d.ts +5 -0
- package/dist/storage/paths.d.ts.map +1 -0
- package/dist/storage/paths.js +26 -0
- package/dist/storage/snapshotState.d.ts +10 -0
- package/dist/storage/snapshotState.d.ts.map +1 -0
- package/dist/storage/snapshotState.js +15 -0
- package/dist/storage/storeTaskArtifacts.d.ts +6 -0
- package/dist/storage/storeTaskArtifacts.d.ts.map +1 -0
- package/dist/storage/storeTaskArtifacts.js +55 -0
- package/dist/storage/types.d.ts +21 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/tasks/crud.d.ts +33 -0
- package/dist/tasks/crud.d.ts.map +1 -0
- package/dist/tasks/crud.js +150 -0
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +9 -0
- package/package.json +141 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GAP-SEC: Authority Chain system.
|
|
4
|
+
*
|
|
5
|
+
* Models delegation chains from human principals through agent principals,
|
|
6
|
+
* with monotonically narrowing scope at each hop.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createAuthorityChain = createAuthorityChain;
|
|
10
|
+
exports.validateAuthorityChain = validateAuthorityChain;
|
|
11
|
+
exports.attenuateScope = attenuateScope;
|
|
12
|
+
exports.traceAuthorityToHuman = traceAuthorityToHuman;
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Core functions
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Create an authority chain from an ordered list of grants.
|
|
18
|
+
* Computes the effective scope as the intersection of all grant scopes.
|
|
19
|
+
*/
|
|
20
|
+
function createAuthorityChain(grants) {
|
|
21
|
+
if (grants.length === 0) {
|
|
22
|
+
throw new Error('Authority chain requires at least one grant');
|
|
23
|
+
}
|
|
24
|
+
const rootPrincipal = grants[0].from;
|
|
25
|
+
// Compute effective scope as intersection of all grant scopes
|
|
26
|
+
let effectiveScope = { ...grants[0].scope, allowedEffectKinds: [...grants[0].scope.allowedEffectKinds] };
|
|
27
|
+
for (let i = 1; i < grants.length; i++) {
|
|
28
|
+
effectiveScope = attenuateScope(effectiveScope, grants[i].scope);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
grants: [...grants],
|
|
32
|
+
rootPrincipal,
|
|
33
|
+
effectiveScope,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate an authority chain. Checks:
|
|
38
|
+
* 1. Root must be a human principal.
|
|
39
|
+
* 2. No revoked links.
|
|
40
|
+
* 3. No expired links.
|
|
41
|
+
* 4. Scopes monotonically narrow (no expansion).
|
|
42
|
+
*/
|
|
43
|
+
function validateAuthorityChain(chain) {
|
|
44
|
+
// 1. Root must be human
|
|
45
|
+
if (chain.rootPrincipal.kind !== 'human') {
|
|
46
|
+
return { valid: false, reason: 'Authority chain must be rooted in a human principal' };
|
|
47
|
+
}
|
|
48
|
+
const now = Date.now();
|
|
49
|
+
for (let i = 0; i < chain.grants.length; i++) {
|
|
50
|
+
const grant = chain.grants[i];
|
|
51
|
+
// 2. No revoked links
|
|
52
|
+
if (grant.revokedAt) {
|
|
53
|
+
return { valid: false, reason: `Grant at index ${i} has been revoked` };
|
|
54
|
+
}
|
|
55
|
+
// 3. No expired links
|
|
56
|
+
if (grant.expiresAt && new Date(grant.expiresAt).getTime() <= now) {
|
|
57
|
+
return { valid: false, reason: `Grant at index ${i} has expired` };
|
|
58
|
+
}
|
|
59
|
+
// 4. Scope must not expand beyond previous grant
|
|
60
|
+
if (i > 0) {
|
|
61
|
+
const parentScope = chain.grants[i - 1].scope;
|
|
62
|
+
const childScope = grant.scope;
|
|
63
|
+
if (!isScopeSubsetOrEqual(parentScope, childScope)) {
|
|
64
|
+
return { valid: false, reason: `Grant at index ${i} expands scope beyond parent` };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { valid: true };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if childScope is a subset of or equal to parentScope.
|
|
72
|
+
*/
|
|
73
|
+
function isScopeSubsetOrEqual(parent, child) {
|
|
74
|
+
// Check effect kinds
|
|
75
|
+
const parentWildcard = parent.allowedEffectKinds.length === 1 && parent.allowedEffectKinds[0] === '*';
|
|
76
|
+
if (!parentWildcard) {
|
|
77
|
+
for (const kind of child.allowedEffectKinds) {
|
|
78
|
+
if (kind === '*') {
|
|
79
|
+
return false; // wildcard child cannot escape non-wildcard parent
|
|
80
|
+
}
|
|
81
|
+
if (!parent.allowedEffectKinds.includes(kind)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Check numeric limits
|
|
87
|
+
if (child.maxIterations > parent.maxIterations)
|
|
88
|
+
return false;
|
|
89
|
+
if (child.maxConcurrentTasks > parent.maxConcurrentTasks)
|
|
90
|
+
return false;
|
|
91
|
+
if (child.timeoutMs > parent.timeoutMs)
|
|
92
|
+
return false;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Attenuate (intersect) two scopes. The result is never wider than either input.
|
|
97
|
+
* Pure function.
|
|
98
|
+
*/
|
|
99
|
+
function attenuateScope(parent, child) {
|
|
100
|
+
const parentWildcard = parent.allowedEffectKinds.length === 1 && parent.allowedEffectKinds[0] === '*';
|
|
101
|
+
const childWildcard = child.allowedEffectKinds.length === 1 && child.allowedEffectKinds[0] === '*';
|
|
102
|
+
let allowedEffectKinds;
|
|
103
|
+
if (parentWildcard && childWildcard) {
|
|
104
|
+
allowedEffectKinds = ['*'];
|
|
105
|
+
}
|
|
106
|
+
else if (parentWildcard) {
|
|
107
|
+
allowedEffectKinds = [...child.allowedEffectKinds];
|
|
108
|
+
}
|
|
109
|
+
else if (childWildcard) {
|
|
110
|
+
allowedEffectKinds = [...parent.allowedEffectKinds];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
allowedEffectKinds = parent.allowedEffectKinds.filter(k => child.allowedEffectKinds.includes(k));
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
allowedEffectKinds,
|
|
117
|
+
maxIterations: Math.min(parent.maxIterations, child.maxIterations),
|
|
118
|
+
maxConcurrentTasks: Math.min(parent.maxConcurrentTasks, child.maxConcurrentTasks),
|
|
119
|
+
timeoutMs: Math.min(parent.timeoutMs, child.timeoutMs),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Trace authority back to the human root, returning the human principal,
|
|
124
|
+
* hop count, and full principal path.
|
|
125
|
+
*/
|
|
126
|
+
function traceAuthorityToHuman(chain) {
|
|
127
|
+
const principalPath = [chain.grants[0].from.id];
|
|
128
|
+
for (const grant of chain.grants) {
|
|
129
|
+
principalPath.push(grant.to.id);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
humanPrincipal: chain.rootPrincipal,
|
|
133
|
+
hopCount: chain.grants.length,
|
|
134
|
+
principalPath,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge from existing breakpoint rules to governance policies (GAP-SEC-001).
|
|
3
|
+
* Converts BreakpointRule[] into PolicyRule[] for unified evaluation.
|
|
4
|
+
*/
|
|
5
|
+
import type { BreakpointRule } from "@a5c-ai/babysitter-sdk";
|
|
6
|
+
import type { PolicyRule } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Convert breakpoint auto-approval rules into governance policy rules.
|
|
9
|
+
*
|
|
10
|
+
* Mapping:
|
|
11
|
+
* - "auto-approve" → allow policy (permission kind)
|
|
12
|
+
* - "never-auto-approve" → deny policy (permission kind)
|
|
13
|
+
*
|
|
14
|
+
* The breakpoint pattern is mapped to a "matches" condition on the taskId field.
|
|
15
|
+
*/
|
|
16
|
+
export declare function breakpointRulesToPolicies(rules: BreakpointRule[]): PolicyRule[];
|
|
17
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/governance/bridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,UAAU,EAAE,CAkB/E"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bridge from existing breakpoint rules to governance policies (GAP-SEC-001).
|
|
4
|
+
* Converts BreakpointRule[] into PolicyRule[] for unified evaluation.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.breakpointRulesToPolicies = breakpointRulesToPolicies;
|
|
8
|
+
/**
|
|
9
|
+
* Convert breakpoint auto-approval rules into governance policy rules.
|
|
10
|
+
*
|
|
11
|
+
* Mapping:
|
|
12
|
+
* - "auto-approve" → allow policy (permission kind)
|
|
13
|
+
* - "never-auto-approve" → deny policy (permission kind)
|
|
14
|
+
*
|
|
15
|
+
* The breakpoint pattern is mapped to a "matches" condition on the taskId field.
|
|
16
|
+
*/
|
|
17
|
+
function breakpointRulesToPolicies(rules) {
|
|
18
|
+
return rules.map(rule => ({
|
|
19
|
+
id: `bp-bridge:${rule.id}`,
|
|
20
|
+
kind: 'permission',
|
|
21
|
+
condition: {
|
|
22
|
+
field: 'taskId',
|
|
23
|
+
op: 'matches',
|
|
24
|
+
value: globToRegex(rule.pattern),
|
|
25
|
+
},
|
|
26
|
+
action: rule.action === 'auto-approve' ? 'allow' : 'deny',
|
|
27
|
+
priority: rule.action === 'never-auto-approve' ? 100 : 50,
|
|
28
|
+
metadata: {
|
|
29
|
+
source: 'breakpoint-bridge',
|
|
30
|
+
originalPattern: rule.pattern,
|
|
31
|
+
createdBy: rule.createdBy,
|
|
32
|
+
...(rule.note ? { note: rule.note } : {}),
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert a simple glob pattern to a regex string.
|
|
38
|
+
* Supports * (any chars) and ? (single char).
|
|
39
|
+
*/
|
|
40
|
+
function globToRegex(glob) {
|
|
41
|
+
const escaped = glob
|
|
42
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
43
|
+
.replace(/\*/g, '.*')
|
|
44
|
+
.replace(/\?/g, '.');
|
|
45
|
+
return `^${escaped}$`;
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in governance policy rules (GAP-SEC-001).
|
|
3
|
+
* Ready-to-use policy factories for common constraints.
|
|
4
|
+
*/
|
|
5
|
+
import type { PolicyRule, StatefulPolicyRule } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Deny effects when the iteration count exceeds a limit.
|
|
8
|
+
*/
|
|
9
|
+
export declare function maxIterationsPolicy(limit: number): PolicyRule;
|
|
10
|
+
/**
|
|
11
|
+
* Deny effects whose effectKind is not in the allowed list.
|
|
12
|
+
* Implemented as a deny rule that matches effectKinds NOT in the list.
|
|
13
|
+
*
|
|
14
|
+
* Since condition ops are single-value, this creates one deny rule per
|
|
15
|
+
* disallowed kind by using a special "neq" with a runtime check.
|
|
16
|
+
* For simplicity, we use a "matches" regex that rejects non-matching kinds.
|
|
17
|
+
*/
|
|
18
|
+
export declare function taskKindPolicy(allowedKinds: string[]): PolicyRule;
|
|
19
|
+
/**
|
|
20
|
+
* Deny effects when the rate exceeds maxCount within windowMs.
|
|
21
|
+
* Uses an in-memory sliding window counter via StatefulPolicyRule.
|
|
22
|
+
* Note: counter resets on process restart (in-memory only).
|
|
23
|
+
*/
|
|
24
|
+
export declare function rateLimitPolicy(windowMs: number, maxCount: number): StatefulPolicyRule;
|
|
25
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/governance/builtins.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAA2B,MAAM,SAAS,CAAC;AAEvF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAS7D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,UAAU,CAUjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAqBtF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in governance policy rules (GAP-SEC-001).
|
|
4
|
+
* Ready-to-use policy factories for common constraints.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.maxIterationsPolicy = maxIterationsPolicy;
|
|
8
|
+
exports.taskKindPolicy = taskKindPolicy;
|
|
9
|
+
exports.rateLimitPolicy = rateLimitPolicy;
|
|
10
|
+
/**
|
|
11
|
+
* Deny effects when the iteration count exceeds a limit.
|
|
12
|
+
*/
|
|
13
|
+
function maxIterationsPolicy(limit) {
|
|
14
|
+
return {
|
|
15
|
+
id: `builtin:max-iterations:${limit}`,
|
|
16
|
+
kind: 'resource-limit',
|
|
17
|
+
condition: { field: 'iteration', op: 'gt', value: String(limit) },
|
|
18
|
+
action: 'deny',
|
|
19
|
+
priority: 90,
|
|
20
|
+
metadata: { description: `Deny when iteration exceeds ${limit}` },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Deny effects whose effectKind is not in the allowed list.
|
|
25
|
+
* Implemented as a deny rule that matches effectKinds NOT in the list.
|
|
26
|
+
*
|
|
27
|
+
* Since condition ops are single-value, this creates one deny rule per
|
|
28
|
+
* disallowed kind by using a special "neq" with a runtime check.
|
|
29
|
+
* For simplicity, we use a "matches" regex that rejects non-matching kinds.
|
|
30
|
+
*/
|
|
31
|
+
function taskKindPolicy(allowedKinds) {
|
|
32
|
+
const pattern = `^(?!${allowedKinds.map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')}$)`;
|
|
33
|
+
return {
|
|
34
|
+
id: `builtin:task-kind:${allowedKinds.join(',')}`,
|
|
35
|
+
kind: 'permission',
|
|
36
|
+
condition: { field: 'effectKind', op: 'matches', value: pattern },
|
|
37
|
+
action: 'deny',
|
|
38
|
+
priority: 80,
|
|
39
|
+
metadata: { description: `Only allow effect kinds: ${allowedKinds.join(', ')}` },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deny effects when the rate exceeds maxCount within windowMs.
|
|
44
|
+
* Uses an in-memory sliding window counter via StatefulPolicyRule.
|
|
45
|
+
* Note: counter resets on process restart (in-memory only).
|
|
46
|
+
*/
|
|
47
|
+
function rateLimitPolicy(windowMs, maxCount) {
|
|
48
|
+
let timestamps = [];
|
|
49
|
+
return {
|
|
50
|
+
id: `builtin:rate-limit:${maxCount}per${windowMs}ms`,
|
|
51
|
+
kind: 'rate-limit',
|
|
52
|
+
// Declarative condition is a no-op placeholder; shouldMatch does the real work
|
|
53
|
+
condition: { field: '__rate_limit__', op: 'eq', value: '__stateful__' },
|
|
54
|
+
action: 'deny',
|
|
55
|
+
priority: 95,
|
|
56
|
+
metadata: {
|
|
57
|
+
description: `Rate limit: ${maxCount} per ${windowMs}ms`,
|
|
58
|
+
},
|
|
59
|
+
shouldMatch(_context) {
|
|
60
|
+
const now = Date.now();
|
|
61
|
+
// Evict expired timestamps with filter (O(n) but no shift overhead)
|
|
62
|
+
timestamps = timestamps.filter(t => t > now - windowMs);
|
|
63
|
+
timestamps.push(now);
|
|
64
|
+
return timestamps.length > maxCount;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GAP-SEC: Deterministic Policy Categories.
|
|
3
|
+
*
|
|
4
|
+
* Categorizes policy rules into A/B/C/D tiers with distinct enforcement
|
|
5
|
+
* behaviors and wraps the base policy engine with category-aware evaluation.
|
|
6
|
+
*/
|
|
7
|
+
import type { PolicyRule, PolicyEvaluationContext, PolicyDecision } from './types';
|
|
8
|
+
/** Policy category identifiers. */
|
|
9
|
+
export type PolicyCategory = 'A' | 'B' | 'C' | 'D';
|
|
10
|
+
/** A PolicyRule annotated with a category. */
|
|
11
|
+
export interface CategorizedPolicyRule extends PolicyRule {
|
|
12
|
+
category?: PolicyCategory;
|
|
13
|
+
}
|
|
14
|
+
/** Enforcement behavior per category. */
|
|
15
|
+
export interface CategoryEnforcementBehavior {
|
|
16
|
+
category: PolicyCategory;
|
|
17
|
+
description: string;
|
|
18
|
+
immutable: boolean;
|
|
19
|
+
requiresClassification: boolean;
|
|
20
|
+
isFallback: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Extended decision with category metadata. */
|
|
23
|
+
export interface CategorizedPolicyDecision extends PolicyDecision {
|
|
24
|
+
requiresClassification?: boolean;
|
|
25
|
+
usedFallback?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Categorized engine interface. */
|
|
28
|
+
export interface CategorizedPolicyEngine {
|
|
29
|
+
readonly rules: readonly CategorizedPolicyRule[];
|
|
30
|
+
evaluate(context: PolicyEvaluationContext): CategorizedPolicyDecision;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Wrap a plain PolicyRule with a category annotation.
|
|
34
|
+
*/
|
|
35
|
+
export declare function categorizePolicyRule(rule: PolicyRule, category: PolicyCategory): CategorizedPolicyRule;
|
|
36
|
+
/**
|
|
37
|
+
* Infer a category for a rule that lacks one.
|
|
38
|
+
*
|
|
39
|
+
* Heuristic:
|
|
40
|
+
* - rate-limit + deny -> A (critical)
|
|
41
|
+
* - permission + deny -> C (needs classification)
|
|
42
|
+
* - trust-level -> D (fallback)
|
|
43
|
+
* - everything else -> B (advisory)
|
|
44
|
+
*/
|
|
45
|
+
export declare function inferPolicyCategory(rule: PolicyRule): PolicyCategory;
|
|
46
|
+
/**
|
|
47
|
+
* Create a categorized policy engine that evaluates rules with
|
|
48
|
+
* category-aware precedence:
|
|
49
|
+
*
|
|
50
|
+
* 1. Category A (immutable) - evaluated first, cannot be overridden
|
|
51
|
+
* 2. Category B (advisory) - warnings / normal evaluation
|
|
52
|
+
* 3. Category C (classification-required) - denials flagged
|
|
53
|
+
* 4. Category D (fallback) - posture-based fallback
|
|
54
|
+
*
|
|
55
|
+
* Accepts CategorizedPolicyRule[] (rules without a category are auto-inferred).
|
|
56
|
+
*/
|
|
57
|
+
export declare function createCategorizedEngine(rules: CategorizedPolicyRule[]): CategorizedPolicyEngine;
|
|
58
|
+
//# sourceMappingURL=categories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/governance/categories.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAMnF,mCAAmC;AACnC,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnD,8CAA8C;AAC9C,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,yCAAyC;AACzC,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,gDAAgD;AAChD,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,oCAAoC;AACpC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,yBAAyB,CAAC;CACvE;AAiBD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,GAAG,qBAAqB,CAEtG;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAKpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,EAAE,GAAG,uBAAuB,CAuE/F"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GAP-SEC: Deterministic Policy Categories.
|
|
4
|
+
*
|
|
5
|
+
* Categorizes policy rules into A/B/C/D tiers with distinct enforcement
|
|
6
|
+
* behaviors and wraps the base policy engine with category-aware evaluation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.categorizePolicyRule = categorizePolicyRule;
|
|
10
|
+
exports.inferPolicyCategory = inferPolicyCategory;
|
|
11
|
+
exports.createCategorizedEngine = createCategorizedEngine;
|
|
12
|
+
const engine_1 = require("./engine");
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Category behaviours
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
const _CATEGORY_BEHAVIORS = {
|
|
17
|
+
A: { category: 'A', description: 'Immutable critical rules', immutable: true, requiresClassification: false, isFallback: false },
|
|
18
|
+
B: { category: 'B', description: 'Advisory rules', immutable: false, requiresClassification: false, isFallback: false },
|
|
19
|
+
C: { category: 'C', description: 'Classification-required rules', immutable: false, requiresClassification: true, isFallback: false },
|
|
20
|
+
D: { category: 'D', description: 'Fallback posture-based rules', immutable: false, requiresClassification: false, isFallback: true },
|
|
21
|
+
};
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Core functions
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
/**
|
|
26
|
+
* Wrap a plain PolicyRule with a category annotation.
|
|
27
|
+
*/
|
|
28
|
+
function categorizePolicyRule(rule, category) {
|
|
29
|
+
return { ...rule, category };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Infer a category for a rule that lacks one.
|
|
33
|
+
*
|
|
34
|
+
* Heuristic:
|
|
35
|
+
* - rate-limit + deny -> A (critical)
|
|
36
|
+
* - permission + deny -> C (needs classification)
|
|
37
|
+
* - trust-level -> D (fallback)
|
|
38
|
+
* - everything else -> B (advisory)
|
|
39
|
+
*/
|
|
40
|
+
function inferPolicyCategory(rule) {
|
|
41
|
+
if (rule.kind === 'rate-limit' && rule.action === 'deny')
|
|
42
|
+
return 'A';
|
|
43
|
+
if (rule.kind === 'permission' && rule.action === 'deny')
|
|
44
|
+
return 'C';
|
|
45
|
+
if (rule.kind === 'trust-level')
|
|
46
|
+
return 'D';
|
|
47
|
+
return 'B';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a categorized policy engine that evaluates rules with
|
|
51
|
+
* category-aware precedence:
|
|
52
|
+
*
|
|
53
|
+
* 1. Category A (immutable) - evaluated first, cannot be overridden
|
|
54
|
+
* 2. Category B (advisory) - warnings / normal evaluation
|
|
55
|
+
* 3. Category C (classification-required) - denials flagged
|
|
56
|
+
* 4. Category D (fallback) - posture-based fallback
|
|
57
|
+
*
|
|
58
|
+
* Accepts CategorizedPolicyRule[] (rules without a category are auto-inferred).
|
|
59
|
+
*/
|
|
60
|
+
function createCategorizedEngine(rules) {
|
|
61
|
+
// Ensure every rule has a category
|
|
62
|
+
const categorized = rules.map(r => r.category ? r : { ...r, category: inferPolicyCategory(r) });
|
|
63
|
+
// Partition by category
|
|
64
|
+
const byCategory = { A: [], B: [], C: [], D: [] };
|
|
65
|
+
for (const rule of categorized) {
|
|
66
|
+
byCategory[rule.category].push(rule);
|
|
67
|
+
}
|
|
68
|
+
// Build per-category engines
|
|
69
|
+
const engineA = (0, engine_1.createPolicyEngine)(byCategory.A);
|
|
70
|
+
const engineB = (0, engine_1.createPolicyEngine)(byCategory.B);
|
|
71
|
+
const engineC = (0, engine_1.createPolicyEngine)(byCategory.C);
|
|
72
|
+
const engineD = (0, engine_1.createPolicyEngine)(byCategory.D);
|
|
73
|
+
return {
|
|
74
|
+
rules: Object.freeze([...categorized]),
|
|
75
|
+
evaluate(context) {
|
|
76
|
+
const allWarnings = [];
|
|
77
|
+
// 1. Category A - immutable, first match wins
|
|
78
|
+
if (byCategory.A.length > 0) {
|
|
79
|
+
const decisionA = engineA.evaluate(context);
|
|
80
|
+
allWarnings.push(...decisionA.warnings);
|
|
81
|
+
if (!decisionA.allowed) {
|
|
82
|
+
return { ...decisionA, warnings: allWarnings };
|
|
83
|
+
}
|
|
84
|
+
// If A explicitly allows, still continue to collect warnings from B
|
|
85
|
+
// but A deny is final.
|
|
86
|
+
}
|
|
87
|
+
// 2. Category B - advisory (collect warnings)
|
|
88
|
+
if (byCategory.B.length > 0) {
|
|
89
|
+
const decisionB = engineB.evaluate(context);
|
|
90
|
+
allWarnings.push(...decisionB.warnings);
|
|
91
|
+
// B deny/allow also applies if no A deny
|
|
92
|
+
if (!decisionB.allowed) {
|
|
93
|
+
return { ...decisionB, warnings: allWarnings };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// 3. Category C - requires classification
|
|
97
|
+
if (byCategory.C.length > 0) {
|
|
98
|
+
const decisionC = engineC.evaluate(context);
|
|
99
|
+
allWarnings.push(...decisionC.warnings);
|
|
100
|
+
if (!decisionC.allowed) {
|
|
101
|
+
return { ...decisionC, warnings: allWarnings, requiresClassification: true };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// 4. Category D - fallback
|
|
105
|
+
if (byCategory.D.length > 0) {
|
|
106
|
+
const decisionD = engineD.evaluate(context);
|
|
107
|
+
allWarnings.push(...decisionD.warnings);
|
|
108
|
+
if (decisionD.rule) {
|
|
109
|
+
return { ...decisionD, warnings: allWarnings, usedFallback: true };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Default allow
|
|
113
|
+
return {
|
|
114
|
+
allowed: true,
|
|
115
|
+
reason: 'Allowed by default policy',
|
|
116
|
+
warnings: allWarnings,
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GAP-OBS-004: Policy Decision Trail.
|
|
3
|
+
*
|
|
4
|
+
* Audit trail for governance policy decisions. Records which policies
|
|
5
|
+
* were evaluated, their results, and the final decision for each
|
|
6
|
+
* effect dispatch.
|
|
7
|
+
*/
|
|
8
|
+
import type { PolicyRule, PolicyDecision } from "./types";
|
|
9
|
+
/** Record of a single policy's evaluation against an effect. */
|
|
10
|
+
export interface PolicyEvalRecord {
|
|
11
|
+
ruleId: string;
|
|
12
|
+
ruleKind: string;
|
|
13
|
+
action: string;
|
|
14
|
+
matched: boolean;
|
|
15
|
+
priority: number;
|
|
16
|
+
}
|
|
17
|
+
/** Full audit entry for one effect dispatch decision. */
|
|
18
|
+
export interface DecisionTrailEntry {
|
|
19
|
+
effectId: string;
|
|
20
|
+
effectKind: string;
|
|
21
|
+
evaluatedAt: string;
|
|
22
|
+
policies: PolicyEvalRecord[];
|
|
23
|
+
finalOutcome: "allow" | "deny";
|
|
24
|
+
decidingRuleId: string | undefined;
|
|
25
|
+
reason: string;
|
|
26
|
+
warnings: string[];
|
|
27
|
+
runId?: string;
|
|
28
|
+
stepId?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Options to build a decision trail entry. */
|
|
31
|
+
export interface DecisionTrailOptions {
|
|
32
|
+
effectId: string;
|
|
33
|
+
effectKind: string;
|
|
34
|
+
rulesEvaluated: PolicyRule[];
|
|
35
|
+
finalDecision: PolicyDecision;
|
|
36
|
+
matchedRuleId?: string;
|
|
37
|
+
runId?: string;
|
|
38
|
+
stepId?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Summary statistics for a set of decision trail entries. */
|
|
41
|
+
export interface DecisionTrailSummary {
|
|
42
|
+
totalEffects: number;
|
|
43
|
+
allowCount: number;
|
|
44
|
+
denyCount: number;
|
|
45
|
+
topDecidingRules: Array<{
|
|
46
|
+
ruleId: string;
|
|
47
|
+
count: number;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build a DecisionTrailEntry from evaluation options.
|
|
52
|
+
* Pure function — no I/O.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildDecisionTrailEntry(options: DecisionTrailOptions): DecisionTrailEntry;
|
|
55
|
+
/**
|
|
56
|
+
* Summarize a collection of decision trail entries.
|
|
57
|
+
* Pure function — no I/O.
|
|
58
|
+
*/
|
|
59
|
+
export declare function summarizeDecisionTrail(entries: DecisionTrailEntry[]): DecisionTrailSummary;
|
|
60
|
+
//# sourceMappingURL=decisionTrail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisionTrail.d.ts","sourceRoot":"","sources":["../../src/governance/decisionTrail.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM1D,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,aAAa,EAAE,cAAc,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAMD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,oBAAoB,GAC5B,kBAAkB,CAqBpB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAAE,GAC5B,oBAAoB,CA8BtB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GAP-OBS-004: Policy Decision Trail.
|
|
4
|
+
*
|
|
5
|
+
* Audit trail for governance policy decisions. Records which policies
|
|
6
|
+
* were evaluated, their results, and the final decision for each
|
|
7
|
+
* effect dispatch.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildDecisionTrailEntry = buildDecisionTrailEntry;
|
|
11
|
+
exports.summarizeDecisionTrail = summarizeDecisionTrail;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Core functions
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Build a DecisionTrailEntry from evaluation options.
|
|
17
|
+
* Pure function — no I/O.
|
|
18
|
+
*/
|
|
19
|
+
function buildDecisionTrailEntry(options) {
|
|
20
|
+
const policies = options.rulesEvaluated.map((rule) => ({
|
|
21
|
+
ruleId: rule.id,
|
|
22
|
+
ruleKind: rule.kind,
|
|
23
|
+
action: rule.action,
|
|
24
|
+
matched: rule.id === options.matchedRuleId,
|
|
25
|
+
priority: rule.priority,
|
|
26
|
+
}));
|
|
27
|
+
return {
|
|
28
|
+
effectId: options.effectId,
|
|
29
|
+
effectKind: options.effectKind,
|
|
30
|
+
evaluatedAt: new Date().toISOString(),
|
|
31
|
+
policies,
|
|
32
|
+
finalOutcome: options.finalDecision.allowed ? "allow" : "deny",
|
|
33
|
+
decidingRuleId: options.matchedRuleId,
|
|
34
|
+
reason: options.finalDecision.reason,
|
|
35
|
+
warnings: options.finalDecision.warnings,
|
|
36
|
+
runId: options.runId,
|
|
37
|
+
stepId: options.stepId,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Summarize a collection of decision trail entries.
|
|
42
|
+
* Pure function — no I/O.
|
|
43
|
+
*/
|
|
44
|
+
function summarizeDecisionTrail(entries) {
|
|
45
|
+
let allowCount = 0;
|
|
46
|
+
let denyCount = 0;
|
|
47
|
+
const ruleFreq = new Map();
|
|
48
|
+
for (const entry of entries) {
|
|
49
|
+
if (entry.finalOutcome === "allow") {
|
|
50
|
+
allowCount++;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
denyCount++;
|
|
54
|
+
}
|
|
55
|
+
if (entry.decidingRuleId) {
|
|
56
|
+
ruleFreq.set(entry.decidingRuleId, (ruleFreq.get(entry.decidingRuleId) ?? 0) + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const topDecidingRules = [...ruleFreq.entries()]
|
|
60
|
+
.map(([ruleId, count]) => ({ ruleId, count }))
|
|
61
|
+
.sort((a, b) => b.count - a.count);
|
|
62
|
+
return {
|
|
63
|
+
totalEffects: entries.length,
|
|
64
|
+
allowCount,
|
|
65
|
+
denyCount,
|
|
66
|
+
topDecidingRules,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance Policy Engine (GAP-SEC-001).
|
|
3
|
+
* Evaluates declarative policy rules with precedence: deny > warn > allow > default-allow.
|
|
4
|
+
*/
|
|
5
|
+
import type { PolicyRule, PolicyCondition, PolicyEvaluationContext, PolicyEngine } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Evaluate a single condition against the evaluation context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function matchCondition(condition: PolicyCondition, context: PolicyEvaluationContext): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Create a policy engine from a set of rules.
|
|
12
|
+
*
|
|
13
|
+
* Evaluation precedence:
|
|
14
|
+
* 1. Deny rules (sorted by priority desc) — first match blocks
|
|
15
|
+
* 2. Warn rules (all matching collected as warnings)
|
|
16
|
+
* 3. Allow rules (sorted by priority desc) — first match allows explicitly
|
|
17
|
+
* 4. Default: allow
|
|
18
|
+
*/
|
|
19
|
+
export declare function createPolicyEngine(rules: PolicyRule[]): PolicyEngine;
|
|
20
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/governance/engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,uBAAuB,EAEvB,YAAY,EACb,MAAM,SAAS,CAAC;AAiBjB;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAwCpG;AAaD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,YAAY,CAmDpE"}
|