@paraharness/fs 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/dist/builders/create-fs-allow-only-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-allow-only-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-allow-only-guard-builder.js +22 -0
- package/dist/builders/create-fs-allow-only-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.d.ts +13 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.d.ts.map +1 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.js +20 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.js.map +1 -0
- package/dist/builders/create-fs-boundary-guard-builder.d.ts +15 -0
- package/dist/builders/create-fs-boundary-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-boundary-guard-builder.js +20 -0
- package/dist/builders/create-fs-boundary-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-coding-tools.d.ts +21 -0
- package/dist/builders/create-fs-coding-tools.d.ts.map +1 -0
- package/dist/builders/create-fs-coding-tools.js +25 -0
- package/dist/builders/create-fs-coding-tools.js.map +1 -0
- package/dist/builders/create-fs-glob-matcher-builder.d.ts +14 -0
- package/dist/builders/create-fs-glob-matcher-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-glob-matcher-builder.js +24 -0
- package/dist/builders/create-fs-glob-matcher-builder.js.map +1 -0
- package/dist/builders/create-fs-glob-source-builder.d.ts +13 -0
- package/dist/builders/create-fs-glob-source-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-glob-source-builder.js +22 -0
- package/dist/builders/create-fs-glob-source-builder.js.map +1 -0
- package/dist/builders/create-fs-in-partition-predicate.d.ts +16 -0
- package/dist/builders/create-fs-in-partition-predicate.d.ts.map +1 -0
- package/dist/builders/create-fs-in-partition-predicate.js +25 -0
- package/dist/builders/create-fs-in-partition-predicate.js.map +1 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.d.ts +29 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.js +30 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.js.map +1 -0
- package/dist/builders/create-fs-max-files-mutated-builder.d.ts +13 -0
- package/dist/builders/create-fs-max-files-mutated-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-max-files-mutated-builder.js +21 -0
- package/dist/builders/create-fs-max-files-mutated-builder.js.map +1 -0
- package/dist/builders/create-fs-partition-map.d.ts +16 -0
- package/dist/builders/create-fs-partition-map.d.ts.map +1 -0
- package/dist/builders/create-fs-partition-map.js +34 -0
- package/dist/builders/create-fs-partition-map.js.map +1 -0
- package/dist/builders/create-fs-protect-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-protect-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-protect-guard-builder.js +22 -0
- package/dist/builders/create-fs-protect-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-read-only-guard-builder.d.ts +11 -0
- package/dist/builders/create-fs-read-only-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-read-only-guard-builder.js +15 -0
- package/dist/builders/create-fs-read-only-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-read-only-tools.d.ts +15 -0
- package/dist/builders/create-fs-read-only-tools.d.ts.map +1 -0
- package/dist/builders/create-fs-read-only-tools.js +23 -0
- package/dist/builders/create-fs-read-only-tools.js.map +1 -0
- package/dist/builders/create-fs-regex-check-builder.d.ts +34 -0
- package/dist/builders/create-fs-regex-check-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-regex-check-builder.js +58 -0
- package/dist/builders/create-fs-regex-check-builder.js.map +1 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.d.ts +11 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.js +15 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.d.ts +15 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.js +20 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.js +21 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-telemetry-builder.d.ts +11 -0
- package/dist/builders/create-fs-telemetry-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-telemetry-builder.js +17 -0
- package/dist/builders/create-fs-telemetry-builder.js.map +1 -0
- package/dist/builders/create-fs-text-source-builder.d.ts +14 -0
- package/dist/builders/create-fs-text-source-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-text-source-builder.js +23 -0
- package/dist/builders/create-fs-text-source-builder.js.map +1 -0
- package/dist/builders/create-fs-write-guard-builder.d.ts +29 -0
- package/dist/builders/create-fs-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-write-guard-builder.js +29 -0
- package/dist/builders/create-fs-write-guard-builder.js.map +1 -0
- package/dist/builders/fs-namespace-contract.d.ts +187 -0
- package/dist/builders/fs-namespace-contract.d.ts.map +1 -0
- package/dist/builders/fs-namespace-contract.js +2 -0
- package/dist/builders/fs-namespace-contract.js.map +1 -0
- package/dist/builders/fs-namespace.d.ts +10 -0
- package/dist/builders/fs-namespace.d.ts.map +1 -0
- package/dist/builders/fs-namespace.js +50 -0
- package/dist/builders/fs-namespace.js.map +1 -0
- package/dist/builders/internal/build-fs-tool-nodes.d.ts +62 -0
- package/dist/builders/internal/build-fs-tool-nodes.d.ts.map +1 -0
- package/dist/builders/internal/build-fs-tool-nodes.js +107 -0
- package/dist/builders/internal/build-fs-tool-nodes.js.map +1 -0
- package/dist/builders/internal/fs-tool-input.schema.d.ts +80 -0
- package/dist/builders/internal/fs-tool-input.schema.d.ts.map +1 -0
- package/dist/builders/internal/fs-tool-input.schema.js +56 -0
- package/dist/builders/internal/fs-tool-input.schema.js.map +1 -0
- package/dist/executors/create-fs-executors.d.ts +11 -0
- package/dist/executors/create-fs-executors.d.ts.map +1 -0
- package/dist/executors/create-fs-executors.js +57 -0
- package/dist/executors/create-fs-executors.js.map +1 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.d.ts +45 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.d.ts.map +1 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.js +99 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.js.map +1 -0
- package/dist/executors/fs-executors.constants.d.ts +10 -0
- package/dist/executors/fs-executors.constants.d.ts.map +1 -0
- package/dist/executors/fs-executors.constants.js +10 -0
- package/dist/executors/fs-executors.constants.js.map +1 -0
- package/dist/executors/fs-glob-effect-matcher.d.ts +15 -0
- package/dist/executors/fs-glob-effect-matcher.d.ts.map +1 -0
- package/dist/executors/fs-glob-effect-matcher.js +37 -0
- package/dist/executors/fs-glob-effect-matcher.js.map +1 -0
- package/dist/executors/fs-path-guard-executors.d.ts +51 -0
- package/dist/executors/fs-path-guard-executors.d.ts.map +1 -0
- package/dist/executors/fs-path-guard-executors.js +60 -0
- package/dist/executors/fs-path-guard-executors.js.map +1 -0
- package/dist/executors/fs-read-tool-drivers.d.ts +35 -0
- package/dist/executors/fs-read-tool-drivers.d.ts.map +1 -0
- package/dist/executors/fs-read-tool-drivers.js +73 -0
- package/dist/executors/fs-read-tool-drivers.js.map +1 -0
- package/dist/executors/fs-source-executors.d.ts +31 -0
- package/dist/executors/fs-source-executors.d.ts.map +1 -0
- package/dist/executors/fs-source-executors.js +55 -0
- package/dist/executors/fs-source-executors.js.map +1 -0
- package/dist/executors/fs-tool-effect.d.ts +33 -0
- package/dist/executors/fs-tool-effect.d.ts.map +1 -0
- package/dist/executors/fs-tool-effect.js +2 -0
- package/dist/executors/fs-tool-effect.js.map +1 -0
- package/dist/executors/fs-write-guard-executors.d.ts +55 -0
- package/dist/executors/fs-write-guard-executors.d.ts.map +1 -0
- package/dist/executors/fs-write-guard-executors.js +64 -0
- package/dist/executors/fs-write-guard-executors.js.map +1 -0
- package/dist/executors/fs-write-tool-drivers.d.ts +24 -0
- package/dist/executors/fs-write-tool-drivers.d.ts.map +1 -0
- package/dist/executors/fs-write-tool-drivers.js +44 -0
- package/dist/executors/fs-write-tool-drivers.js.map +1 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.d.ts +9 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.d.ts.map +1 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.js +24 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.js.map +1 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.d.ts +12 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.js +59 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.js.map +1 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.d.ts +13 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.js +42 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.js.map +1 -0
- package/dist/executors/internal/collect-read-paths-from-effects.d.ts +12 -0
- package/dist/executors/internal/collect-read-paths-from-effects.d.ts.map +1 -0
- package/dist/executors/internal/collect-read-paths-from-effects.js +26 -0
- package/dist/executors/internal/collect-read-paths-from-effects.js.map +1 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.d.ts +14 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.d.ts.map +1 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.js +50 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.js.map +1 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.d.ts +12 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.d.ts.map +1 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.js +63 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.js.map +1 -0
- package/dist/executors/internal/compile-secret-patterns.d.ts +12 -0
- package/dist/executors/internal/compile-secret-patterns.d.ts.map +1 -0
- package/dist/executors/internal/compile-secret-patterns.js +27 -0
- package/dist/executors/internal/compile-secret-patterns.js.map +1 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.d.ts +13 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.d.ts.map +1 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.js +33 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.js.map +1 -0
- package/dist/executors/internal/create-fs-read-effect.d.ts +12 -0
- package/dist/executors/internal/create-fs-read-effect.d.ts.map +1 -0
- package/dist/executors/internal/create-fs-read-effect.js +22 -0
- package/dist/executors/internal/create-fs-read-effect.js.map +1 -0
- package/dist/executors/internal/create-fs-write-effect.d.ts +14 -0
- package/dist/executors/internal/create-fs-write-effect.d.ts.map +1 -0
- package/dist/executors/internal/create-fs-write-effect.js +24 -0
- package/dist/executors/internal/create-fs-write-effect.js.map +1 -0
- package/dist/executors/internal/describe-fs-edit-effects.d.ts +13 -0
- package/dist/executors/internal/describe-fs-edit-effects.d.ts.map +1 -0
- package/dist/executors/internal/describe-fs-edit-effects.js +31 -0
- package/dist/executors/internal/describe-fs-edit-effects.js.map +1 -0
- package/dist/executors/internal/describe-fs-write-effects.d.ts +13 -0
- package/dist/executors/internal/describe-fs-write-effects.d.ts.map +1 -0
- package/dist/executors/internal/describe-fs-write-effects.js +24 -0
- package/dist/executors/internal/describe-fs-write-effects.js.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.d.ts +12 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.d.ts.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.js +52 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.js.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files.d.ts +13 -0
- package/dist/executors/internal/enumerate-workspace-files.d.ts.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files.js +44 -0
- package/dist/executors/internal/enumerate-workspace-files.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.d.ts +28 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.js +37 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.d.ts +20 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.js +46 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.d.ts +31 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.js +100 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.js.map +1 -0
- package/dist/executors/internal/execute-fs-edit-operation.d.ts +26 -0
- package/dist/executors/internal/execute-fs-edit-operation.d.ts.map +1 -0
- package/dist/executors/internal/execute-fs-edit-operation.js +25 -0
- package/dist/executors/internal/execute-fs-edit-operation.js.map +1 -0
- package/dist/executors/internal/execute-fs-write-operation.d.ts +22 -0
- package/dist/executors/internal/execute-fs-write-operation.d.ts.map +1 -0
- package/dist/executors/internal/execute-fs-write-operation.js +21 -0
- package/dist/executors/internal/execute-fs-write-operation.js.map +1 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.d.ts +15 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.js +24 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.js.map +1 -0
- package/dist/executors/internal/filter-jailed-dirents.d.ts +25 -0
- package/dist/executors/internal/filter-jailed-dirents.d.ts.map +1 -0
- package/dist/executors/internal/filter-jailed-dirents.js +54 -0
- package/dist/executors/internal/filter-jailed-dirents.js.map +1 -0
- package/dist/executors/internal/fs-coding-tool-drivers.d.ts +38 -0
- package/dist/executors/internal/fs-coding-tool-drivers.d.ts.map +1 -0
- package/dist/executors/internal/fs-coding-tool-drivers.js +52 -0
- package/dist/executors/internal/fs-coding-tool-drivers.js.map +1 -0
- package/dist/executors/internal/fs-search-tool-drivers.d.ts +26 -0
- package/dist/executors/internal/fs-search-tool-drivers.d.ts.map +1 -0
- package/dist/executors/internal/fs-search-tool-drivers.js +37 -0
- package/dist/executors/internal/fs-search-tool-drivers.js.map +1 -0
- package/dist/executors/internal/glob-matcher-cache.constants.d.ts +20 -0
- package/dist/executors/internal/glob-matcher-cache.constants.d.ts.map +1 -0
- package/dist/executors/internal/glob-matcher-cache.constants.js +19 -0
- package/dist/executors/internal/glob-matcher-cache.constants.js.map +1 -0
- package/dist/executors/internal/grep-workspace-files.d.ts +23 -0
- package/dist/executors/internal/grep-workspace-files.d.ts.map +1 -0
- package/dist/executors/internal/grep-workspace-files.js +33 -0
- package/dist/executors/internal/grep-workspace-files.js.map +1 -0
- package/dist/executors/internal/project-violated-write-effects.d.ts +15 -0
- package/dist/executors/internal/project-violated-write-effects.d.ts.map +1 -0
- package/dist/executors/internal/project-violated-write-effects.js +67 -0
- package/dist/executors/internal/project-violated-write-effects.js.map +1 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.d.ts +19 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.d.ts.map +1 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.js +101 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.js.map +1 -0
- package/dist/executors/internal/secret-patterns.constants.d.ts +16 -0
- package/dist/executors/internal/secret-patterns.constants.d.ts.map +1 -0
- package/dist/executors/internal/secret-patterns.constants.js +30 -0
- package/dist/executors/internal/secret-patterns.constants.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/stores/fs-jsonl-lesson-store.d.ts +135 -0
- package/dist/stores/fs-jsonl-lesson-store.d.ts.map +1 -0
- package/dist/stores/fs-jsonl-lesson-store.js +155 -0
- package/dist/stores/fs-jsonl-lesson-store.js.map +1 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.d.ts +129 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.d.ts.map +1 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.js +197 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.js.map +1 -0
- package/dist/stores/internal/fs-lesson-definition-record.d.ts +19 -0
- package/dist/stores/internal/fs-lesson-definition-record.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-definition-record.js +2 -0
- package/dist/stores/internal/fs-lesson-definition-record.js.map +1 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.d.ts +51 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.js +89 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.js.map +1 -0
- package/dist/stores/internal/fs-lesson-relevance.d.ts +49 -0
- package/dist/stores/internal/fs-lesson-relevance.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-relevance.js +113 -0
- package/dist/stores/internal/fs-lesson-relevance.js.map +1 -0
- package/dist/stores/internal/fs-lesson-stats-entry.d.ts +22 -0
- package/dist/stores/internal/fs-lesson-stats-entry.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-stats-entry.js +2 -0
- package/dist/stores/internal/fs-lesson-stats-entry.js.map +1 -0
- package/package.json +72 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-allow-and-protect-guards.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-allow-and-protect-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CAO7B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CAM7B;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,oBAAoB,EAC1B,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CAO7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { compileGlobOrExactMatcher } from './compile-glob-or-exact-matcher.js';
|
|
2
|
+
import { projectViolatedWriteEffects } from './project-violated-write-effects.js';
|
|
3
|
+
/**
|
|
4
|
+
* Evaluates `FsProtectGuardNode` path globs against proposed write effects.
|
|
5
|
+
*
|
|
6
|
+
* @param {FsProtectGuardNode} node - Protect guard AST node.
|
|
7
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
8
|
+
*
|
|
9
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
10
|
+
*/
|
|
11
|
+
export function evaluateFsProtectPaths(node, input) {
|
|
12
|
+
const isProtectedMatch = compileGlobOrExactMatcher(node.globs);
|
|
13
|
+
return projectViolatedWriteEffects(input, (relPath) => isProtectedMatch(relPath), (paths) => `Protected file write denied on [${paths.join(', ')}]`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Evaluates `FsReadOnlyGuardNode` against proposed write effects.
|
|
17
|
+
*
|
|
18
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
19
|
+
*
|
|
20
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
21
|
+
*/
|
|
22
|
+
export function evaluateFsReadOnlyPaths(input) {
|
|
23
|
+
return projectViolatedWriteEffects(input, () => true, (paths) => `Read-only policy violation: write denied on [${paths.join(', ')}]`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Evaluates `FsAllowOnlyGuardNode` path globs against proposed write effects.
|
|
27
|
+
*
|
|
28
|
+
* @param {FsAllowOnlyGuardNode} node - Allow-only guard AST node.
|
|
29
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
30
|
+
*
|
|
31
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
32
|
+
*/
|
|
33
|
+
export function evaluateFsAllowOnlyPaths(node, input) {
|
|
34
|
+
const isAllowedMatch = compileGlobOrExactMatcher(node.globs);
|
|
35
|
+
return projectViolatedWriteEffects(input, (relPath) => !isAllowedMatch(relPath), (paths) => `Write outside allowOnly globs denied on [${paths.join(', ')}]`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=evaluate-fs-allow-and-protect-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-allow-and-protect-guards.js","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-allow-and-protect-guards.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAwB,EACxB,KAAiC;IAEjC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACtC,CAAC,KAAK,EAAE,EAAE,CAAC,mCAAmC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAClE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAiC;IAEjC,OAAO,2BAA2B,CAChC,KAAK,EACL,GAAG,EAAE,CAAC,IAAI,EACV,CAAC,KAAK,EAAE,EAAE,CAAC,gDAAgD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC/E,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAA0B,EAC1B,KAAiC;IAEjC,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EACrC,CAAC,KAAK,EAAE,EAAE,CAAC,4CAA4C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FsSecretLiteralsGuardNode, PolicyGuardEvaluationInput, PolicyGuardEvaluationResult, StepExecutionContext } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Evaluates `FsRequireReadBeforeWriteGuardNode` against `ctx.observedEffects` and `existingPathsAtBaseRef`.
|
|
4
|
+
*
|
|
5
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
6
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context providing `observedEffects`.
|
|
7
|
+
*
|
|
8
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
9
|
+
*/
|
|
10
|
+
export declare function evaluateFsReadBeforeWritePaths(input: PolicyGuardEvaluationInput, ctx: StepExecutionContext<unknown>): PolicyGuardEvaluationResult;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluates `FsSecretLiteralsGuardNode` against `proposedContent` in proposed write effects.
|
|
13
|
+
*
|
|
14
|
+
* @param {FsSecretLiteralsGuardNode} node - Secret literals guard AST node.
|
|
15
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
16
|
+
*
|
|
17
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluateFsSecretLiteralPaths(node: FsSecretLiteralsGuardNode, input: PolicyGuardEvaluationInput): PolicyGuardEvaluationResult;
|
|
20
|
+
//# sourceMappingURL=evaluate-fs-content-and-read-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-content-and-read-guards.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-content-and-read-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,0BAA0B,EACjC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,2BAA2B,CAW7B;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,yBAAyB,EAC/B,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CAkB7B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { collectReadPathsFromEffects } from './collect-read-paths-from-effects.js';
|
|
2
|
+
import { compileSecretPatterns } from './compile-secret-patterns.js';
|
|
3
|
+
import { createEffectBaseRefPathLookup } from './create-effect-base-ref-path-lookup.js';
|
|
4
|
+
import { projectViolatedWriteEffects } from './project-violated-write-effects.js';
|
|
5
|
+
/**
|
|
6
|
+
* Evaluates `FsRequireReadBeforeWriteGuardNode` against `ctx.observedEffects` and `existingPathsAtBaseRef`.
|
|
7
|
+
*
|
|
8
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
9
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context providing `observedEffects`.
|
|
10
|
+
*
|
|
11
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
12
|
+
*/
|
|
13
|
+
export function evaluateFsReadBeforeWritePaths(input, ctx) {
|
|
14
|
+
const readPaths = collectReadPathsFromEffects(ctx.observedEffects);
|
|
15
|
+
const existsAtBaseRef = createEffectBaseRefPathLookup(ctx.scopeHandle);
|
|
16
|
+
return projectViolatedWriteEffects(input, (relPath, eff) => {
|
|
17
|
+
if (readPaths.has(relPath))
|
|
18
|
+
return false;
|
|
19
|
+
return existsAtBaseRef(eff, relPath);
|
|
20
|
+
}, (paths) => `Read-before-write required prior to mutating existing file(s) [${paths.join(', ')}]`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Evaluates `FsSecretLiteralsGuardNode` against `proposedContent` in proposed write effects.
|
|
24
|
+
*
|
|
25
|
+
* @param {FsSecretLiteralsGuardNode} node - Secret literals guard AST node.
|
|
26
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
27
|
+
*
|
|
28
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
29
|
+
*/
|
|
30
|
+
export function evaluateFsSecretLiteralPaths(node, input) {
|
|
31
|
+
const secretRegexes = compileSecretPatterns(node.patterns);
|
|
32
|
+
return projectViolatedWriteEffects(input, (relPath, eff) => {
|
|
33
|
+
const proposedMap = eff.attributes?.['proposedContent'];
|
|
34
|
+
if (proposedMap === undefined)
|
|
35
|
+
return false;
|
|
36
|
+
const content = proposedMap[relPath];
|
|
37
|
+
if (typeof content !== 'string' || content.length === 0)
|
|
38
|
+
return false;
|
|
39
|
+
for (const regex of secretRegexes) {
|
|
40
|
+
if (regex.test(content))
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}, (paths) => `Secret literal detected in proposed write to [${paths.join(', ')}]`);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=evaluate-fs-content-and-read-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-content-and-read-guards.js","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-content-and-read-guards.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF;;;;;;;GAOG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAiC,EACjC,GAAkC;IAElC,MAAM,SAAS,GAAG,2BAA2B,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,6BAA6B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvE,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACf,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QACzC,OAAO,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,kEAAkE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjG,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAA+B,EAC/B,KAAiC;IAEjC,MAAM,aAAa,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3D,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACf,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC,iBAAiB,CAEzC,CAAC;QACd,IAAI,WAAW,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC5C,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACtE,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;gBAAE,OAAO,IAAI,CAAC;QACvC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,iDAAiD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FsBoundaryGuardNode, FsScopedWriteGuardNode, FsWriteGuardNode, PolicyGuardEvaluationInput, PolicyGuardEvaluationResult, StepExecutionContext } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Evaluates `FsBoundaryGuardNode` partition `boundaryGlobs` against proposed write effects.
|
|
4
|
+
*
|
|
5
|
+
* @param {FsBoundaryGuardNode} node - Boundary guard AST node.
|
|
6
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
7
|
+
*
|
|
8
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
9
|
+
*/
|
|
10
|
+
export declare function evaluateFsBoundaryPaths(node: FsBoundaryGuardNode, input: PolicyGuardEvaluationInput): PolicyGuardEvaluationResult;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluates `FsWriteGuardNode` (`denyGlobs`, `allowGlobs`, `onlyExistingAtBaseRef`) against proposed write effects.
|
|
13
|
+
*
|
|
14
|
+
* @param {FsWriteGuardNode} node - Write guard AST node.
|
|
15
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
16
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context.
|
|
17
|
+
*
|
|
18
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
19
|
+
*/
|
|
20
|
+
export declare function evaluateFsWriteGuardPaths(node: FsWriteGuardNode, input: PolicyGuardEvaluationInput, ctx: StepExecutionContext<unknown>): PolicyGuardEvaluationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Evaluates `FsScopedWriteGuardNode` active partition member `globs` against proposed write effects.
|
|
23
|
+
*
|
|
24
|
+
* @param {FsScopedWriteGuardNode} node - Scoped write guard AST node.
|
|
25
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
26
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context providing `activePartitions`.
|
|
27
|
+
*
|
|
28
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
29
|
+
*/
|
|
30
|
+
export declare function evaluateFsScopedWritePaths(node: FsScopedWriteGuardNode, input: PolicyGuardEvaluationInput, ctx: StepExecutionContext<unknown>): PolicyGuardEvaluationResult;
|
|
31
|
+
//# sourceMappingURL=evaluate-fs-write-and-boundary-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-write-and-boundary-guards.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-write-and-boundary-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAwC3B;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,0BAA0B,GAChC,2BAA2B,CAO7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,0BAA0B,EACjC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,2BAA2B,CAc7B;AAyBD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,sBAAsB,EAC5B,KAAK,EAAE,0BAA0B,EACjC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,2BAA2B,CAO7B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { compileGlobOrExactMatcher } from './compile-glob-or-exact-matcher.js';
|
|
2
|
+
import { createEffectBaseRefPathLookup } from './create-effect-base-ref-path-lookup.js';
|
|
3
|
+
import { CACHED_BOUNDARY_GUARD_MATCHERS } from './glob-matcher-cache.constants.js';
|
|
4
|
+
import { projectViolatedWriteEffects } from './project-violated-write-effects.js';
|
|
5
|
+
/**
|
|
6
|
+
* Pre-compiles and memoizes a boundary path matcher across all partitions in `node.partitionMap` (`Rules 4.2 & 4.4`).
|
|
7
|
+
*
|
|
8
|
+
* Iterates `Object.keys(node.partitionMap.mapping)` once on a cold `WeakMap` miss, compiling each
|
|
9
|
+
* partition's frozen `boundaryGlobs` slice via `compileGlobOrExactMatcher` and caching the composed predicate on `node`.
|
|
10
|
+
*
|
|
11
|
+
* @param {FsBoundaryGuardNode} node - Boundary guard AST node.
|
|
12
|
+
*
|
|
13
|
+
* @returns {(candidatePath: string) => boolean} Memoized synchronous predicate returning `true` when `candidatePath` is a boundary file.
|
|
14
|
+
*/
|
|
15
|
+
function compileBoundaryGuardMatcher(node) {
|
|
16
|
+
const cached = CACHED_BOUNDARY_GUARD_MATCHERS.get(node);
|
|
17
|
+
if (cached !== undefined) {
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
const partitionMatchers = [];
|
|
21
|
+
for (const partitionKey of Object.keys(node.partitionMap.mapping)) {
|
|
22
|
+
const entry = node.partitionMap.mapping[partitionKey];
|
|
23
|
+
if (entry !== undefined) {
|
|
24
|
+
partitionMatchers.push(compileGlobOrExactMatcher(entry.boundaryGlobs));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const compiled = (candidatePath) => {
|
|
28
|
+
for (const isMatch of partitionMatchers) {
|
|
29
|
+
if (isMatch(candidatePath))
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
CACHED_BOUNDARY_GUARD_MATCHERS.set(node, compiled);
|
|
35
|
+
return compiled;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Evaluates `FsBoundaryGuardNode` partition `boundaryGlobs` against proposed write effects.
|
|
39
|
+
*
|
|
40
|
+
* @param {FsBoundaryGuardNode} node - Boundary guard AST node.
|
|
41
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
42
|
+
*
|
|
43
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
44
|
+
*/
|
|
45
|
+
export function evaluateFsBoundaryPaths(node, input) {
|
|
46
|
+
const isBoundaryMatch = compileBoundaryGuardMatcher(node);
|
|
47
|
+
return projectViolatedWriteEffects(input, (relPath) => isBoundaryMatch(relPath), (paths) => `Protected partition boundary write denied on [${paths.join(', ')}]`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Evaluates `FsWriteGuardNode` (`denyGlobs`, `allowGlobs`, `onlyExistingAtBaseRef`) against proposed write effects.
|
|
51
|
+
*
|
|
52
|
+
* @param {FsWriteGuardNode} node - Write guard AST node.
|
|
53
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
54
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context.
|
|
55
|
+
*
|
|
56
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
57
|
+
*/
|
|
58
|
+
export function evaluateFsWriteGuardPaths(node, input, ctx) {
|
|
59
|
+
const isDenied = compileGlobOrExactMatcher(node.denyGlobs);
|
|
60
|
+
const isAllowed = node.allowGlobs !== undefined ? compileGlobOrExactMatcher(node.allowGlobs) : () => false;
|
|
61
|
+
const existsAtBaseRef = createEffectBaseRefPathLookup(ctx.scopeHandle);
|
|
62
|
+
return projectViolatedWriteEffects(input, (relPath, eff) => {
|
|
63
|
+
if (isAllowed(relPath) || !isDenied(relPath))
|
|
64
|
+
return false;
|
|
65
|
+
if (node.onlyExistingAtBaseRef !== true)
|
|
66
|
+
return true;
|
|
67
|
+
return existsAtBaseRef(eff, relPath);
|
|
68
|
+
}, (paths) => `Write guard '${node.id}' denied mutation on [${paths.join(', ')}]`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Tests whether `relPath` matches at least one active partition's `globs` in `node.partitionMap` (`Rules 4.2 & 4.4`).
|
|
72
|
+
*
|
|
73
|
+
* @param {FsScopedWriteGuardNode} node - Scoped write guard AST node.
|
|
74
|
+
* @param {readonly string[]} activePartitions - Active partition identifiers for the step.
|
|
75
|
+
* @param {string} relPath - Normalized worktree-relative file path.
|
|
76
|
+
*
|
|
77
|
+
* @returns {boolean} True when `relPath` belongs to at least one active partition.
|
|
78
|
+
*/
|
|
79
|
+
function isPathInActivePartitions(node, activePartitions, relPath) {
|
|
80
|
+
for (const partitionId of activePartitions) {
|
|
81
|
+
const entry = node.partitionMap.mapping[partitionId];
|
|
82
|
+
if (entry !== undefined && compileGlobOrExactMatcher(entry.globs)(relPath)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Evaluates `FsScopedWriteGuardNode` active partition member `globs` against proposed write effects.
|
|
90
|
+
*
|
|
91
|
+
* @param {FsScopedWriteGuardNode} node - Scoped write guard AST node.
|
|
92
|
+
* @param {PolicyGuardEvaluationInput} input - Proposed effects and active capability leases.
|
|
93
|
+
* @param {StepExecutionContext<unknown>} ctx - Step execution context providing `activePartitions`.
|
|
94
|
+
*
|
|
95
|
+
* @returns {PolicyGuardEvaluationResult} Frozen policy guard evaluation result.
|
|
96
|
+
*/
|
|
97
|
+
export function evaluateFsScopedWritePaths(node, input, ctx) {
|
|
98
|
+
return projectViolatedWriteEffects(input, (relPath) => !isPathInActivePartitions(node, ctx.activePartitions, relPath), (paths) => `Scoped write denied outside active partitions [${ctx.activePartitions.join(', ')}] on [${paths.join(', ')}]`);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=evaluate-fs-write-and-boundary-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-fs-write-and-boundary-guards.js","sourceRoot":"","sources":["../../../src/executors/internal/evaluate-fs-write-and-boundary-guards.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF;;;;;;;;;GASG;AACH,SAAS,2BAA2B,CAClC,IAAyB;IAEzB,MAAM,MAAM,GAAG,8BAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,iBAAiB,GAA8C,EAAE,CAAC;IACxE,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,iBAAiB,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,aAAqB,EAAW,EAAE;QAClD,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;YACxC,IAAI,OAAO,CAAC,aAAa,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC1C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IACF,8BAA8B,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAyB,EACzB,KAAiC;IAEjC,MAAM,eAAe,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,EACrC,CAAC,KAAK,EAAE,EAAE,CAAC,iDAAiD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAAsB,EACtB,KAAiC,EACjC,GAAkC;IAElC,MAAM,QAAQ,GAAG,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,MAAM,SAAS,GACb,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAY,EAAE,CAAC,KAAK,CAAC;IACpG,MAAM,eAAe,GAAG,6BAA6B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvE,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACf,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3D,IAAI,IAAI,CAAC,qBAAqB,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACrD,OAAO,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,IAAI,CAAC,EAAE,yBAAyB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC/E,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,wBAAwB,CAC/B,IAA4B,EAC5B,gBAAmC,EACnC,OAAe;IAEf,KAAK,MAAM,WAAW,IAAI,gBAAgB,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,KAAK,KAAK,SAAS,IAAI,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3E,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAA4B,EAC5B,KAAiC,EACjC,GAAkC;IAElC,OAAO,2BAA2B,CAChC,KAAK,EACL,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAC3E,CAAC,KAAK,EAAE,EAAE,CACR,kDAAkD,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ToolExecutionResult } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Validated edit arguments for {@link executeFsEditOperation}.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExecuteFsEditOperationParams {
|
|
6
|
+
/** Workspace-relative path of the file to edit. */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
/** Exact substring to replace. */
|
|
9
|
+
readonly oldString: string;
|
|
10
|
+
/** Replacement string. */
|
|
11
|
+
readonly newString: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Executes a jailed `edit_file` string replacement inside `scopeHandle`.
|
|
15
|
+
*
|
|
16
|
+
* Verifies that `params.oldString` exists in the target file before writing the updated UTF-8 text.
|
|
17
|
+
*
|
|
18
|
+
* @param {unknown} scopeHandle - Active isolation scope handle.
|
|
19
|
+
* @param {ExecuteFsEditOperationParams} params - Validated edit arguments (`path`, `oldString`, `newString`).
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} If `params.oldString` is not found in the target file.
|
|
24
|
+
*/
|
|
25
|
+
export declare function executeFsEditOperation(scopeHandle: unknown, params: ExecuteFsEditOperationParams): Promise<ToolExecutionResult>;
|
|
26
|
+
//# sourceMappingURL=execute-fs-edit-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-fs-edit-operation.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/execute-fs-edit-operation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAe9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolveJailedWorktreePath } from './resolve-jailed-worktree-path.js';
|
|
3
|
+
/**
|
|
4
|
+
* Executes a jailed `edit_file` string replacement inside `scopeHandle`.
|
|
5
|
+
*
|
|
6
|
+
* Verifies that `params.oldString` exists in the target file before writing the updated UTF-8 text.
|
|
7
|
+
*
|
|
8
|
+
* @param {unknown} scopeHandle - Active isolation scope handle.
|
|
9
|
+
* @param {ExecuteFsEditOperationParams} params - Validated edit arguments (`path`, `oldString`, `newString`).
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} If `params.oldString` is not found in the target file.
|
|
14
|
+
*/
|
|
15
|
+
export async function executeFsEditOperation(scopeHandle, params) {
|
|
16
|
+
const { normalizedRelPath, absolutePath } = resolveJailedWorktreePath(scopeHandle, params.path, 'write');
|
|
17
|
+
const currentContent = await readFile(absolutePath, 'utf8');
|
|
18
|
+
if (!currentContent.includes(params.oldString)) {
|
|
19
|
+
throw new Error(`fs:edit failed on '${normalizedRelPath}': target oldString was not found in file.`);
|
|
20
|
+
}
|
|
21
|
+
const updatedContent = currentContent.replace(params.oldString, () => params.newString);
|
|
22
|
+
await writeFile(absolutePath, updatedContent, 'utf8');
|
|
23
|
+
return Object.freeze({ content: `Edited ${normalizedRelPath}` });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=execute-fs-edit-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-fs-edit-operation.js","sourceRoot":"","sources":["../../../src/executors/internal/execute-fs-edit-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAgB9E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAoB,EACpB,MAAoC;IAEpC,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,yBAAyB,CACnE,WAAW,EACX,MAAM,CAAC,IAAI,EACX,OAAO,CACR,CAAC;IACF,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC5D,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,sBAAsB,iBAAiB,4CAA4C,CACpF,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACxF,MAAM,SAAS,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC,MAAM,CAAsB,EAAE,OAAO,EAAE,UAAU,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ToolExecutionResult } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Validated write arguments for {@link executeFsWriteOperation}.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExecuteFsWriteOperationParams {
|
|
6
|
+
/** Workspace-relative path of the file to write. */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
/** UTF-8 file content to write. */
|
|
9
|
+
readonly content: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Executes a jailed `write_file` operation inside `scopeHandle`.
|
|
13
|
+
*
|
|
14
|
+
* Creates parent directories if needed, re-verifies symlink jailing, and writes UTF-8 text.
|
|
15
|
+
*
|
|
16
|
+
* @param {unknown} scopeHandle - Active isolation scope handle.
|
|
17
|
+
* @param {ExecuteFsWriteOperationParams} params - Validated write arguments (`path`, `content`).
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
20
|
+
*/
|
|
21
|
+
export declare function executeFsWriteOperation(scopeHandle: unknown, params: ExecuteFsWriteOperationParams): Promise<ToolExecutionResult>;
|
|
22
|
+
//# sourceMappingURL=execute-fs-write-operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-fs-write-operation.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/execute-fs-write-operation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,mBAAmB,CAAC,CAU9B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveJailedWorktreePath } from './resolve-jailed-worktree-path.js';
|
|
4
|
+
/**
|
|
5
|
+
* Executes a jailed `write_file` operation inside `scopeHandle`.
|
|
6
|
+
*
|
|
7
|
+
* Creates parent directories if needed, re-verifies symlink jailing, and writes UTF-8 text.
|
|
8
|
+
*
|
|
9
|
+
* @param {unknown} scopeHandle - Active isolation scope handle.
|
|
10
|
+
* @param {ExecuteFsWriteOperationParams} params - Validated write arguments (`path`, `content`).
|
|
11
|
+
*
|
|
12
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
13
|
+
*/
|
|
14
|
+
export async function executeFsWriteOperation(scopeHandle, params) {
|
|
15
|
+
const { normalizedRelPath, absolutePath } = resolveJailedWorktreePath(scopeHandle, params.path, 'write');
|
|
16
|
+
await mkdir(path.dirname(absolutePath), { recursive: true });
|
|
17
|
+
resolveJailedWorktreePath(scopeHandle, normalizedRelPath, 'write');
|
|
18
|
+
await writeFile(absolutePath, params.content, 'utf8');
|
|
19
|
+
return Object.freeze({ content: `Wrote ${normalizedRelPath}` });
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=execute-fs-write-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-fs-write-operation.js","sourceRoot":"","sources":["../../../src/executors/internal/execute-fs-write-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAa9E;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,WAAoB,EACpB,MAAqC;IAErC,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,yBAAyB,CACnE,WAAW,EACX,MAAM,CAAC,IAAI,EACX,OAAO,CACR,CAAC;IACF,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,yBAAyB,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC,MAAM,CAAsB,EAAE,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts `rootPath` and optional `baseRef` from an opaque isolation `scopeHandle`.
|
|
3
|
+
*
|
|
4
|
+
* Defaults `rootPath` to `process.cwd()` when `scopeHandle` does not carry a `worktreePath`
|
|
5
|
+
* string (`SPEC.md` Invariant 5 & §4.3).
|
|
6
|
+
*
|
|
7
|
+
* @param {unknown} scopeHandle - Active isolation scope handle or `undefined`.
|
|
8
|
+
*
|
|
9
|
+
* @returns {{ readonly rootPath: string; readonly baseRef: string | undefined }} Resolved root directory and optional git `baseRef`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractWorktreeRootAndBaseRef(scopeHandle: unknown): {
|
|
12
|
+
readonly rootPath: string;
|
|
13
|
+
readonly baseRef: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=extract-worktree-root-and-base-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-worktree-root-and-base-ref.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/extract-worktree-root-and-base-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAcA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts `rootPath` and optional `baseRef` from an opaque isolation `scopeHandle`.
|
|
3
|
+
*
|
|
4
|
+
* Defaults `rootPath` to `process.cwd()` when `scopeHandle` does not carry a `worktreePath`
|
|
5
|
+
* string (`SPEC.md` Invariant 5 & §4.3).
|
|
6
|
+
*
|
|
7
|
+
* @param {unknown} scopeHandle - Active isolation scope handle or `undefined`.
|
|
8
|
+
*
|
|
9
|
+
* @returns {{ readonly rootPath: string; readonly baseRef: string | undefined }} Resolved root directory and optional git `baseRef`.
|
|
10
|
+
*/
|
|
11
|
+
export function extractWorktreeRootAndBaseRef(scopeHandle) {
|
|
12
|
+
if (typeof scopeHandle !== 'object' || scopeHandle === null) {
|
|
13
|
+
return Object.freeze({ rootPath: process.cwd(), baseRef: undefined });
|
|
14
|
+
}
|
|
15
|
+
const record = scopeHandle;
|
|
16
|
+
const rawWorktreePath = record['worktreePath'];
|
|
17
|
+
const rootPath = typeof rawWorktreePath === 'string' && rawWorktreePath.trim().length > 0
|
|
18
|
+
? rawWorktreePath
|
|
19
|
+
: process.cwd();
|
|
20
|
+
const rawBaseRef = record['baseRef'];
|
|
21
|
+
const baseRef = typeof rawBaseRef === 'string' && rawBaseRef.trim().length > 0 ? rawBaseRef : undefined;
|
|
22
|
+
return Object.freeze({ rootPath, baseRef });
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=extract-worktree-root-and-base-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-worktree-root-and-base-ref.js","sourceRoot":"","sources":["../../../src/executors/internal/extract-worktree-root-and-base-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAAC,WAAoB;IAIhE,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,MAAM,GAAG,WAAgD,CAAC;IAChE,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;IAC/C,MAAM,QAAQ,GACZ,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACtE,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IACpB,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,OAAO,GACX,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Dirent } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for {@link filterJailedDirents}.
|
|
4
|
+
*/
|
|
5
|
+
export interface FilterJailedDirentsParams {
|
|
6
|
+
/** Canonicalized `realpathSync` root directory of the workspace. */
|
|
7
|
+
readonly realRoot: string;
|
|
8
|
+
/** Set of canonical directory paths already visited in this walk. */
|
|
9
|
+
readonly visitedDirs: Set<string>;
|
|
10
|
+
/** Current directory path being read by `tinyglobby`. */
|
|
11
|
+
readonly dirPath: string;
|
|
12
|
+
/** Raw directory entries returned by `fs.readdir`. */
|
|
13
|
+
readonly entries: readonly Dirent[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Filters directory entries for `tinyglobby` so symlinks escaping `realRoot`, broken symlinks, and cycles are skipped.
|
|
17
|
+
*
|
|
18
|
+
* Enforces `realpathSync` containment inside `realRoot` and prevents cyclic directory symlink recursion.
|
|
19
|
+
*
|
|
20
|
+
* @param {FilterJailedDirentsParams} params - Canonical root, visited directory set, current directory, and raw dirents.
|
|
21
|
+
*
|
|
22
|
+
* @returns {Dirent[]} Filtered array of jailed directory entries.
|
|
23
|
+
*/
|
|
24
|
+
export declare function filterJailedDirents(params: FilterJailedDirentsParams): Dirent[];
|
|
25
|
+
//# sourceMappingURL=filter-jailed-dirents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-jailed-dirents.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/filter-jailed-dirents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAA0B,MAAM,SAAS,CAAC;AAG9D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAElC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,EAAE,CA0C/E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Filters directory entries for `tinyglobby` so symlinks escaping `realRoot`, broken symlinks, and cycles are skipped.
|
|
5
|
+
*
|
|
6
|
+
* Enforces `realpathSync` containment inside `realRoot` and prevents cyclic directory symlink recursion.
|
|
7
|
+
*
|
|
8
|
+
* @param {FilterJailedDirentsParams} params - Canonical root, visited directory set, current directory, and raw dirents.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Dirent[]} Filtered array of jailed directory entries.
|
|
11
|
+
*/
|
|
12
|
+
export function filterJailedDirents(params) {
|
|
13
|
+
let realDir;
|
|
14
|
+
try {
|
|
15
|
+
realDir = realpathSync(params.dirPath);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const dirRel = path.relative(params.realRoot, realDir);
|
|
21
|
+
if (dirRel === '..' ||
|
|
22
|
+
dirRel.startsWith('../') ||
|
|
23
|
+
dirRel.startsWith(`..${path.sep}`) ||
|
|
24
|
+
path.isAbsolute(dirRel)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const allowed = [];
|
|
28
|
+
for (const entry of params.entries) {
|
|
29
|
+
if (entry.name === '.git' || entry.name === 'node_modules')
|
|
30
|
+
continue;
|
|
31
|
+
let realTarget;
|
|
32
|
+
try {
|
|
33
|
+
realTarget = realpathSync(path.join(params.dirPath, entry.name));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const rel = path.relative(params.realRoot, realTarget);
|
|
39
|
+
if (rel === '..' || rel.startsWith('../') || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (entry.isSymbolicLink() && statSync(realTarget).isDirectory()) {
|
|
43
|
+
if (params.visitedDirs.has(realTarget) ||
|
|
44
|
+
realDir === realTarget ||
|
|
45
|
+
realDir.startsWith(`${realTarget}${path.sep}`)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
params.visitedDirs.add(realTarget);
|
|
49
|
+
}
|
|
50
|
+
allowed.push(entry);
|
|
51
|
+
}
|
|
52
|
+
return allowed;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=filter-jailed-dirents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-jailed-dirents.js","sourceRoot":"","sources":["../../../src/executors/internal/filter-jailed-dirents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAmB7B;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiC;IACnE,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,IACE,MAAM,KAAK,IAAI;QACf,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;QACxB,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EACvB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc;YAAE,SAAS;QACrE,IAAI,UAAkB,CAAC;QACvB,IAAI,CAAC;YACH,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACnE,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACvD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrG,SAAS;QACX,CAAC;QACD,IAAI,KAAK,CAAC,cAAc,EAAE,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACjE,IACE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;gBAClC,OAAO,KAAK,UAAU;gBACtB,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,EAC9C,CAAC;gBACD,SAAS;YACX,CAAC;YACD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FsEditToolNode, FsReadToolNode, FsWriteToolNode, StepExecutionContext, ToolExecutionResult } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Validates `args` against `node.inputSchema` and reads the jailed UTF-8 file for `fs:read`.
|
|
4
|
+
*
|
|
5
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
6
|
+
*
|
|
7
|
+
* @param {FsReadToolNode<THandle>} node - Passive `fs:read` tool AST node.
|
|
8
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
9
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result containing the UTF-8 file text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readFsToolFile<THandle = unknown>(node: FsReadToolNode<THandle>, args: unknown, ctx: StepExecutionContext<THandle>): Promise<ToolExecutionResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Validates `args` against `node.inputSchema` and executes a jailed `fs:edit` replacement.
|
|
16
|
+
*
|
|
17
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
18
|
+
*
|
|
19
|
+
* @param {FsEditToolNode<THandle>} node - Passive `fs:edit` tool AST node.
|
|
20
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
21
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
24
|
+
*/
|
|
25
|
+
export declare function editFsToolFile<THandle = unknown>(node: FsEditToolNode<THandle>, args: unknown, ctx: StepExecutionContext<THandle>): Promise<ToolExecutionResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Validates `args` against `node.inputSchema` and executes a jailed `fs:write` operation.
|
|
28
|
+
*
|
|
29
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
30
|
+
*
|
|
31
|
+
* @param {FsWriteToolNode<THandle>} node - Passive `fs:write` tool AST node.
|
|
32
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
33
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeFsToolFile<THandle = unknown>(node: FsWriteToolNode<THandle>, args: unknown, ctx: StepExecutionContext<THandle>): Promise<ToolExecutionResult>;
|
|
38
|
+
//# sourceMappingURL=fs-coding-tool-drivers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-coding-tool-drivers.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/fs-coding-tool-drivers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAW3B;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAG,OAAO,EACpD,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,EAC7B,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAK9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAG,OAAO,EAC9C,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,EAC7B,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAG9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAG,OAAO,EAC/C,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,EAC9B,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { executeFsEditOperation, } from './execute-fs-edit-operation.js';
|
|
3
|
+
import { executeFsWriteOperation, } from './execute-fs-write-operation.js';
|
|
4
|
+
import { resolveJailedWorktreePath } from './resolve-jailed-worktree-path.js';
|
|
5
|
+
/**
|
|
6
|
+
* Validates `args` against `node.inputSchema` and reads the jailed UTF-8 file for `fs:read`.
|
|
7
|
+
*
|
|
8
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
9
|
+
*
|
|
10
|
+
* @param {FsReadToolNode<THandle>} node - Passive `fs:read` tool AST node.
|
|
11
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
12
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result containing the UTF-8 file text.
|
|
15
|
+
*/
|
|
16
|
+
export async function readFsToolFile(node, args, ctx) {
|
|
17
|
+
const parsed = node.inputSchema.parse(args);
|
|
18
|
+
const { absolutePath } = resolveJailedWorktreePath(ctx.scopeHandle, parsed.path, 'read');
|
|
19
|
+
const content = await readFile(absolutePath, 'utf8');
|
|
20
|
+
return Object.freeze({ content });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validates `args` against `node.inputSchema` and executes a jailed `fs:edit` replacement.
|
|
24
|
+
*
|
|
25
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
26
|
+
*
|
|
27
|
+
* @param {FsEditToolNode<THandle>} node - Passive `fs:edit` tool AST node.
|
|
28
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
29
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
30
|
+
*
|
|
31
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
32
|
+
*/
|
|
33
|
+
export function editFsToolFile(node, args, ctx) {
|
|
34
|
+
const parsed = node.inputSchema.parse(args);
|
|
35
|
+
return executeFsEditOperation(ctx.scopeHandle, parsed);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validates `args` against `node.inputSchema` and executes a jailed `fs:write` operation.
|
|
39
|
+
*
|
|
40
|
+
* @template THandle Runtime handle type of the active isolation scope.
|
|
41
|
+
*
|
|
42
|
+
* @param {FsWriteToolNode<THandle>} node - Passive `fs:write` tool AST node.
|
|
43
|
+
* @param {unknown} args - Raw tool call arguments.
|
|
44
|
+
* @param {StepExecutionContext<THandle>} ctx - Active step execution context.
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise<ToolExecutionResult>} Frozen tool execution result.
|
|
47
|
+
*/
|
|
48
|
+
export function writeFsToolFile(node, args, ctx) {
|
|
49
|
+
const parsed = node.inputSchema.parse(args);
|
|
50
|
+
return executeFsWriteOperation(ctx.scopeHandle, parsed);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=fs-coding-tool-drivers.js.map
|